Skip to content

Commit

Permalink
fixed excessive template noise in details views
Browse files Browse the repository at this point in the history
  • Loading branch information
marzer committed Aug 6, 2023
1 parent c3cac87 commit 4363152
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.13.4 - 2023-08-06

- fixed excessive `template<>` noise in details views

## v0.13.3 - 2023-08-01

- fixed floating TOCs sometimes clipping off the bottom of the screen when the viewport was vertically narrow
Expand Down
6 changes: 6 additions & 0 deletions src/poxy/css/poxy-overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ figure.m-figure > figcaption {
display: block;
}

/* hiding the 'parent' template info in details blocks */
.m-doc-details .m-doc-template .m-doc-template-parent,
.m-doc-details .m-doc-template .m-doc-template-parent + br {
display: none;
}

/* killing <wbr> tags in function details table template lists */
section.m-doc-details div .m-table.m-fullwidth.m-flat tbody td:first-of-type wbr {
display: none;
Expand Down
18 changes: 18 additions & 0 deletions src/poxy/fixers.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,23 @@ def __call__(self, context: Context, doc: soup.HTMLDocument, path: Path):
return count > 0


class RemoveTemplateNoise(HTMLFixer):
'''
Removes some template noise from detail blocks.
'''

def __call__(self, context: Context, doc: soup.HTMLDocument, path: Path):
tags = [tag for tag in doc.article.find_all(r'span', class_='m-doc-wrap-bumper-prefix') if not tag.decomposed]
changed = False
for tag in tags:
m = re.fullmatch(r'([a-zA-Z_][a-zA-Z_0-9:]*)<.+?>::', tag.get_text())
if not m:
continue
tag.string = rf'{m[1]}::'
changed = True
return changed


# =======================================================================================================================
# plain text post-processes
# =======================================================================================================================
Expand Down Expand Up @@ -1158,4 +1175,5 @@ def __call__(self, context: Context, text: str, path: Path) -> str:
'Pygments',
'InstallSearchShim',
'DeducedAutoReturnType',
'RemoveTemplateNoise',
]
2 changes: 2 additions & 0 deletions src/poxy/generated/poxy.css
Original file line number Diff line number Diff line change
Expand Up @@ -2816,6 +2816,8 @@ margin-top: initial;
.m-info:not(.m-note, .m-button) a:active { color: var(--info-link-active-color); }
.m-doc-template-params.m-doc-template-long { display: block; padding-left: 1rem; }
.m-doc-template-params.m-doc-template-long .m-doc-template-param::before { content: ""; display: block; }
.m-doc-details .m-doc-template .m-doc-template-parent,
.m-doc-details .m-doc-template .m-doc-template-parent + br { display: none; }
section.m-doc-details div .m-table.m-fullwidth.m-flat tbody td:first-of-type wbr { display: none; }
.poxy-about-the-author { margin-top: 4rem; }
.poxy-about-the-author .poxy-socials { display: block; padding-top: 0.5rem; }
Expand Down
13 changes: 10 additions & 3 deletions src/poxy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ def make_boolean_optional_arg(args, name, default, help='', **kwargs):
args.add_argument(rf'--{name}', default=default, help=help, action=argparse.BooleanOptionalAction, **kwargs)
else:
args.add_argument(rf'--{name}', action=r'store_true', help=help, **kwargs)
args.add_argument(rf'--no-{name}', action=r'store_false', dest=name, **kwargs)
args.add_argument(
rf'--no-{name}',
action=r'store_false',
help=(help if help == argparse.SUPPRESS else None),
dest=name,
**kwargs,
)
args.set_defaults(**{name: default})


Expand Down Expand Up @@ -140,7 +146,7 @@ def main(invoker=True):
args.add_argument(r'--nocleanup', action=r'store_true', help=argparse.SUPPRESS) #
args.add_argument(r'--noassets', action=r'store_true', help=argparse.SUPPRESS) #
args.add_argument(r'--update-styles', action=r'store_true', help=argparse.SUPPRESS) #
args.add_argument(r'--update-fonts', action=r'store_true', help=argparse.SUPPRESS) #
make_boolean_optional_arg(args, r'update-fonts', default=None, help=argparse.SUPPRESS)
args.add_argument(r'--update-emoji', action=r'store_true', help=argparse.SUPPRESS) #
args.add_argument(r'--update-tests', action=r'store_true', help=argparse.SUPPRESS) #
args.add_argument(
Expand Down Expand Up @@ -175,7 +181,8 @@ def main(invoker=True):

if args.mcss is not None:
args.update_styles = True
args.update_fonts = True
if args.update_fonts is None:
args.update_fonts = True
mcss.update_bundled_install(args.mcss)
assert_existing_directory(paths.MCSS)
assert_existing_file(Path(paths.MCSS, r'documentation/doxygen.py'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>
<div class="m-doc-include m-code m-inverted m-right-m m-text-right"><span class="cp">#include</span> <a class="cpf" href="{{ compound.include[1] }}">{{ compound.include[0] }}</a></div>
{% endif %}
{% set j = joiner(', ') %}
<div class="m-doc-template">template&lt;<span class="m-doc-template-params{% if compound.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in compound.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif%}</span>{% endfor %}</span>&gt;</div>
<div class="m-doc-template">template&nbsp;&lt;<span class="m-doc-template-params{% if compound.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in compound.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif%}</span>{% endfor %}</span>&gt;</div>
{% endif %}
{%+ for name, target in compound.breadcrumb[:-1] %}<span class="m-breadcrumb"><a href="{{ target }}">{{ name }}</a>::<wbr/></span>{% endfor %}{{ compound.breadcrumb[-1][0] }} <span class="m-thin">{{ compound.kind }}</span>{% if compound.is_final %} <span class="m-label m-flat m-warning">final</span>{% endif %}{% if compound.since %} {{ compound.since }}{% endif %}
{# need an explicit space here otherwise the newline gets removed #}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ <h3>
{% if compound.templates != None %}
<div class="m-doc-template">
{% set j = joiner(', ') %}
template&lt;{% for t in compound.templates %}{{ j() }}{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}{% endfor %}&gt;
template&nbsp;&lt;<span class="m-doc-template-params{% if compound.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in compound.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}</span>{% endfor %}</span>&gt;
</div>
{% endif %}
enum {% if enum.is_strong %}class {% endif %}{{ prefix }}<a href="#{{ enum.id }}" class="m-doc-self">{{ enum.name }}</a>{% if enum.type %}: {{ enum.type }}{% endif %}{% if enum.is_protected %} <span class="m-label m-warning">protected</span>{% endif %}{% if enum.since %} {{ enum.since }}{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ <h3>
<div class="m-doc-template">
{% if compound.templates != None %}
{% set j = joiner(', ') %}
template&lt;<span class="m-doc-template-params{% if compound.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in compound.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}</span>{% endfor %}</span>&gt;
<span class="m-doc-template-parent">template&nbsp;&lt;<span class="m-doc-template-params{% if compound.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in compound.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}</span>{% endfor %}</span>&gt;</span>
{% endif %}
{% if compound.templates != None and func.templates != None %}
<br>
{% endif %}
{% if func.templates != None %}
{% set j = joiner(', ') %}
template&lt;<span class="m-doc-template-params{% if func.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in func.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}</span>{% endfor %}</span>&gt;
template&nbsp;&lt;<span class="m-doc-template-params{% if func.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in func.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}</span>{% endfor %}</span>&gt;
{% endif %}
</div>
{% endif %}
{% set j = joiner(',\n ') %}
<span class="m-doc-wrap-bumper">{{ func.prefix }}{{ func.type }} {{ prefix }}</span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#{{ func.id }}" class="m-doc-self">{{ func.name }}</a>(</span><span class="m-doc-wrap">{% for param in func.params %}{{ j() }}{{ param.type_name }}{% if param.default %} = {{ param.default }}{% endif %}{% endfor %}){{ func.suffix }}{% if func.is_explicit %} <span class="m-label m-info">explicit</span> {% endif %}{% if func.is_final %} <span class="m-label m-warning">final</span>{% elif func.is_override %} <span class="m-label m-warning">override</span>{% elif func.is_pure_virtual %} <span class="m-label m-warning">pure virtual</span>{% elif func.is_virtual %} <span class="m-label m-warning">virtual</span>{% endif %}{% if func.is_protected %} <span class="m-label m-warning">protected{% if func.is_slot %} slot{% endif %}</span>{% elif func.is_private %} <span class="m-label m-danger">private{% if func.is_slot %} slot{% endif %}</span>{% elif func.is_signal %} <span class="m-label m-success">signal</span>{% elif func.is_slot %} <span class="m-label m-success">public slot</span>{% endif %}{% if func.is_defaulted %} <span class="m-label m-info">defaulted</span>{% endif %}{% if func.is_deleted %} <span class="m-label m-danger">deleted</span>{% endif %}{% if func.is_consteval %} <span class="m-label m-primary">consteval</span>{% elif func.is_constexpr %} <span class="m-label m-primary">constexpr</span>{% endif %}{% if func.is_conditional_noexcept %} <span class="m-label m-success">noexcept(…)</span>{% elif func.is_noexcept %} <span class="m-label m-success">noexcept</span>{% endif %}{% if func.since %} {{ func.since }}{% endif %}</span></span>
<span class="m-doc-wrap-bumper">{{ func.prefix }}{{ func.type }} <span class="m-doc-wrap-bumper-prefix">{{ prefix }}</span></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#{{ func.id }}" class="m-doc-self">{{ func.name }}</a>(</span><span class="m-doc-wrap">{% for param in func.params %}{{ j() }}{{ param.type_name }}{% if param.default %} = {{ param.default }}{% endif %}{% endfor %}){{ func.suffix }}{% if func.is_explicit %} <span class="m-label m-info">explicit</span> {% endif %}{% if func.is_final %} <span class="m-label m-warning">final</span>{% elif func.is_override %} <span class="m-label m-warning">override</span>{% elif func.is_pure_virtual %} <span class="m-label m-warning">pure virtual</span>{% elif func.is_virtual %} <span class="m-label m-warning">virtual</span>{% endif %}{% if func.is_protected %} <span class="m-label m-warning">protected{% if func.is_slot %} slot{% endif %}</span>{% elif func.is_private %} <span class="m-label m-danger">private{% if func.is_slot %} slot{% endif %}</span>{% elif func.is_signal %} <span class="m-label m-success">signal</span>{% elif func.is_slot %} <span class="m-label m-success">public slot</span>{% endif %}{% if func.is_defaulted %} <span class="m-label m-info">defaulted</span>{% endif %}{% if func.is_deleted %} <span class="m-label m-danger">deleted</span>{% endif %}{% if func.is_consteval %} <span class="m-label m-primary">consteval</span>{% elif func.is_constexpr %} <span class="m-label m-primary">constexpr</span>{% endif %}{% if func.is_conditional_noexcept %} <span class="m-label m-success">noexcept(…)</span>{% elif func.is_noexcept %} <span class="m-label m-success">noexcept</span>{% endif %}{% if func.since %} {{ func.since }}{% endif %}</span></span>
{% if func.include and compound.templates == None and func.templates == None %}
<div class="m-doc-include m-code m-inverted m-text-right"><span class="cp">#include</span> <a class="cpf" href="{{ func.include[1] }}">{{ func.include[0] }}</a></div>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ <h3>
<div class="m-doc-template">
{% if compound.templates != None %}
{% set j = joiner(', ') %}
template&lt;<span class="m-doc-template-params{% if compound.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in compound.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}</span>{% endfor %}</span>&gt;
<span class="m-doc-template-parent">template&nbsp;&lt;<span class="m-doc-template-params{% if compound.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in compound.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}</span>{% endfor %}</span>&gt;</span>
{% endif %}
{% if compound.templates != None and typedef.templates != None %}
<br>
{% endif %}
{% if typedef.templates != None %}
{% set j = joiner(', ') %}
template&lt;<span class="m-doc-template-params{% if typedef.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in typedef.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}</span>{% endfor %}</span>&gt;
template&nbsp;&lt;<span class="m-doc-template-params{% if typedef.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in typedef.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}</span>{% endfor %}</span>&gt;
{% endif %}
</div>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ <h3>
<div class="m-doc-template">
{% if compound.templates != None %}
{% set j = joiner(', ') %}
template&lt;<span class="m-doc-template-params{% if compound.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in compound.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}</span>{% endfor %}</span>&gt;
<span class="m-doc-template-parent">template&nbsp;&lt;<span class="m-doc-template-params{% if compound.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in compound.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}</span>{% endfor %}</span>&gt;</span>
{% endif %}
{% if compound.templates != None and var.templates != None %}
<br>
{% endif %}
{% if var.templates != None %}
{% set j = joiner(', ') %}
template&lt;<span class="m-doc-template-params{% if var.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in var.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}</span>{% endfor %}</span>&gt;
template&nbsp;&lt;<span class="m-doc-template-params{% if var.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in var.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}</span>{% endfor %}</span>&gt;
{% endif %}
</div>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<dt>
{% if class.templates != None %}
{% set j = joiner(', ') %}
<div class="m-doc-template">template&lt;<span class="m-doc-template-params{% if class.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in class.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}</span>{% endfor %}</span>&gt;</div>
<div class="m-doc-template">template&nbsp;&lt;<span class="m-doc-template-params{% if class.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in class.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}</span>{% endfor %}</span>&gt;</div>
{% endif %}
{{ class.kind }} <a href="{{ class.url }}" class="m-doc">{{ class.name }}</a>{% if class.is_protected %} <span class="m-label m-flat m-warning">protected</span>{% endif %}{% if class.is_final %} <span class="m-label m-flat m-warning">final</span>{% elif class.is_virtual %} <span class="m-label m-flat m-warning">virtual</span>{% endif %}{% if class.deprecated %} <span class="m-label m-danger">{{ class.deprecated }}</span>{% endif %}{% if class.since %} {{ class.since }}{% endif %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<dt>
{% if concept.templates != None %}
{% set j = joiner(', ') %}
<div class="m-doc-template">template&lt;{% for t in concept.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}&gt;</div>
<div class="m-doc-template">template&nbsp;&lt;<span class="m-doc-template-params{% if concept.templates|length >= 3 %} m-doc-template-long{% endif %}">{% for t in concept.templates %}{{ j() }}<span class="m-doc-template-param">{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}</span>{% endfor %}</span>&gt;</div>
{% endif %}
{{ concept.kind }} <a href="{{ concept.url }}" class="m-doc">{{ concept.name }}</a>{% if concept.is_protected %} <span class="m-label m-flat m-warning">protected</span>{% endif %}{% if concept.deprecated %} <span class="m-label m-danger">{{ concept.deprecated }}</span>{% endif %}{% if concept.since %} {{ concept.since }}{% endif %}

Expand Down
Loading

0 comments on commit 4363152

Please sign in to comment.