Skip to content

Conversation

@marmarek
Copy link
Member

Make it produce less white spaces/empty lines and make it work with translated pages.
See individual commits for details.

@marmarek marmarek force-pushed the doc-index-patch branch 2 times, most recently from 708022d to ab19cb2 Compare June 23, 2021 03:47
Comment on lines 46 to 48
{% for page in all_docs %}{% if page.url == sub.url -%}
<li><a href="{{ sub.url }}">{{ page.title }}</a></li>
{%- endif %}{% endfor %}
Copy link
Member

@andrewdavidwong andrewdavidwong Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have only one opening/closing operator per line? In other words:

{% for page in all_docs %}
  {% if page.url == sub.url -%}
    <li><a href="{{ sub.url }}">{{ page.title }}</a></li>
  {%- endif  %}
{% endfor %}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only thing I want to confirm before merging.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@andrewdavidwong
Copy link
Member

Mark single-line statements with '-' at the end, to strip blanks after
it - otherwise lines like {% assign ... %} will produce empty line in
the output.
Do the same with 'for' loops and embedded 'if' inside, but be careful to
not strip too much, to still insert newlines between list items (loop
iterations).

Neat trick! I didn't know about it.

This is especially important for loops iterating many times (like,
enumerating the whole site.doc), otherwise the output may be a huge file
of mostly spaces and newlines. With translated repo included, I managed
to get about 800KB doc index file...

Yes, I noticed that too. In general, the best solution (after the improvements you've made here) would be to minify our output. This method sounds like it might be promising, and there are many others discussed on the web.

Furthermore, optimize external doc generation. Specifically - do
not iterate over the whole site.doc for external docs - those won't
match anyway. This saves about 2s of site build time.

Good catch. Thank you!

Also, iterate over subpages/subpages3 once, not twice. This IMO makes
it easier to follow - it's more obvious the entry is either external doc
or not - but not both.

Ok, thank you.

marmarek added 2 commits June 23, 2021 23:06
Mark single-line statements with '-' at the end, to strip blanks after
it - otherwise lines like {% assign ... %} will produce empty line in
the output.
Do the same with 'for' loops and embedded 'if' inside, but be careful to
not strip too much, to still insert newlines between list items (loop
iterations).
This is especially important for loops iterating many times (like,
enumerating the whole site.doc), otherwise the output may be a huge file
of mostly spaces and newlines. With translated repo included, I managed
to get about 800KB doc index file...

Furthermore, optimize external doc generation. Specifically - do
not iterate over the whole site.doc for external docs - those won't
match anyway. This saves about 2s of site build time.

Also, iterate over subpages/subpages3 once, not twice. This IMO makes
it easier to follow - it's more obvious the entry is either external doc
or not - but not both.
1. Distinguish doc index using appropriate language-specific permalink.
   Fortunately, doc-heading.html already sets 'doc_link' variable.
2. For translated doc, iterate over site.translated, instead of
   site.doc.
@andrewdavidwong andrewdavidwong merged commit ddebefe into QubesOS:master Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants