-
Notifications
You must be signed in to change notification settings - Fork 440
Reduce the number of useless new lines in html doc #759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I looked a it a little bit. It's probably related to ERB because the template have empty lines but is not responsible of all those extra lines. I am on Ruby 2.7 and the trim mode seems ok. I will keep digging. |
It is more related to an ERB behavior. I don't see an easy way at the moment to do not create empty lines and don't break indentation. require 'erb'
expected = %{
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
}
template_unindented = %{
<ul>
<% list = [1,2,3] %>
<% for item in list %>
<% if item %>
<li><%= item %></li>
<% end %>
<% end %>
</ul>
} # space is needed for correct formating
template_indented = %{
<ul>
<% list = [1,2,3] %>
<% for item in list %>
<% if item %>
<li><%= item %></li>
<% end %>
<% end %>
</ul>
}
templates = [
{
name: 'template_unindented',
trim_mode: '<>',
content: template_unindented
},
{
name: 'template_indented',
trim_mode: '<>',
content: template_indented
},
{
name: 'template_indented',
trim_mode: '%>',
content: template_indented
},
{
name: 'template_indented',
trim_mode: '-',
content: template_indented
}
]
templates.each do |template|
puts "🎲 With trim_mode: #{template[:trim_mode]}, for #{template[:name]}\n\n"
pp ERB.new(template[:content], trim_mode: template[:trim_mode]).result
puts
end
puts "🎲 Expected\n\n"
pp expected
|
Ok so with the last version and the One example in --- a/lib/rdoc/generator/template/darkfish/class.rhtml
+++ b/lib/rdoc/generator/template/darkfish/class.rhtml
@@ -122,28 +122,26 @@
<% end %>
<div class="method-description">
- <% if method.comment then %>
+ <%- if method.comment then -%>
<%= method.description.strip %>
- <% else %>
+ <%- else -%>
<p class="missing-docs">(Not documented)
- <% end %>
- <% if method.calls_super then %>
+ <%- end -%>
+ <%- if method.calls_super then -%>
<div class="method-calls-super">
Calls superclass method
<%=
method.superclass_method ?
method.formatter.link(method.superclass_method.full_name, method.superclass_method.full_name) : nil
- %>
+ -%>
</div>
- <% end %>
-
- <% if method.token_stream then %>
- <div class="method-source-code" id="<%= method.html_name %>-source">
- <pre><%= method.markup_code %></pre>
+ <%- end -%>
+ <%- if method.token_stream then -%>
+ <div class="method-source-code" id="<%= method.html_name -%>-source">
+ <pre><%= method.markup_code -%></pre>
</div>
- <% end %>
+ <%- end -%>
</div>
- Produce this diff in the html: --- a/Shape-master.html
+++ b/Shape-new.html
@@ -129,19 +129,12 @@
<div class="method-description">
-
-
-
-
-
<div class="method-source-code" id="new-source">
<pre><span class="ruby-comment"># File shape.rb, line 2</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">polyline</span>)
<span class="ruby-keyword">end</span></pre>
</div>
-
</div>
- I still have a blank line, but if I remove it I will have an indentation issue: - <%= method.description.strip%>
+ <%= method.description.strip -%> I will jump from :
To :
So it is possible to fix some of the extra lines, but it requires to pass on all templates. Do you want this? |
Hello
With
rdoc
6.2.1 and the ruby code:I get an html with a lot of extra lines and trailing whitespace.
Is it something that can be fixed?
I can look at it
The text was updated successfully, but these errors were encountered: