From 43631524a15ea3c5b1156e84a9911640b8b372ae Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Sun, 6 Aug 2023 17:21:35 +0300 Subject: [PATCH] fixed excessive `template` noise in details views --- CHANGELOG.md | 4 ++++ src/poxy/css/poxy-overrides.css | 6 ++++++ src/poxy/fixers.py | 18 ++++++++++++++++++ src/poxy/generated/poxy.css | 2 ++ src/poxy/main.py | 13 ++++++++++--- .../doxygen/base-class-reference.html | 2 +- .../templates/doxygen/details-enum.html | 2 +- .../templates/doxygen/details-func.html | 6 +++--- .../templates/doxygen/details-typedef.html | 4 ++-- .../templates/doxygen/details-var.html | 4 ++-- .../templates/doxygen/entry-class.html | 2 +- .../templates/doxygen/entry-concept.html | 2 +- .../templates/doxygen/entry-func.html | 2 +- .../templates/doxygen/entry-typedef.html | 2 +- .../templates/doxygen/entry-var.html | 2 +- src/poxy/run.py | 1 + src/poxy/version.txt | 2 +- 17 files changed, 56 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61795c1..fbd8be5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/poxy/css/poxy-overrides.css b/src/poxy/css/poxy-overrides.css index 6d3349e..3761db2 100644 --- a/src/poxy/css/poxy-overrides.css +++ b/src/poxy/css/poxy-overrides.css @@ -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 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; diff --git a/src/poxy/fixers.py b/src/poxy/fixers.py index 3042d80..530d619 100644 --- a/src/poxy/fixers.py +++ b/src/poxy/fixers.py @@ -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 # ======================================================================================================================= @@ -1158,4 +1175,5 @@ def __call__(self, context: Context, text: str, path: Path) -> str: 'Pygments', 'InstallSearchShim', 'DeducedAutoReturnType', + 'RemoveTemplateNoise', ] diff --git a/src/poxy/generated/poxy.css b/src/poxy/generated/poxy.css index 3912256..c47ae14 100644 --- a/src/poxy/generated/poxy.css +++ b/src/poxy/generated/poxy.css @@ -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; } diff --git a/src/poxy/main.py b/src/poxy/main.py index 0e264fb..4d9b0c5 100644 --- a/src/poxy/main.py +++ b/src/poxy/main.py @@ -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}) @@ -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( @@ -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')) diff --git a/src/poxy/mcss/documentation/templates/doxygen/base-class-reference.html b/src/poxy/mcss/documentation/templates/doxygen/base-class-reference.html index 9a49545..0df1a67 100644 --- a/src/poxy/mcss/documentation/templates/doxygen/base-class-reference.html +++ b/src/poxy/mcss/documentation/templates/doxygen/base-class-reference.html @@ -23,7 +23,7 @@

{% endif %} {% set j = joiner(', ') %} -
template<{% for t in compound.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif%}{% endfor %}>
+
template <{% for t in compound.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif%}{% endfor %}>
{% endif %} {%+ for name, target in compound.breadcrumb[:-1] %}{{ name }}::{% endfor %}{{ compound.breadcrumb[-1][0] }} {{ compound.kind }}{% if compound.is_final %} final{% endif %}{% if compound.since %} {{ compound.since }}{% endif %} {# need an explicit space here otherwise the newline gets removed #} diff --git a/src/poxy/mcss/documentation/templates/doxygen/details-enum.html b/src/poxy/mcss/documentation/templates/doxygen/details-enum.html index 0134304..d3cb8ff 100644 --- a/src/poxy/mcss/documentation/templates/doxygen/details-enum.html +++ b/src/poxy/mcss/documentation/templates/doxygen/details-enum.html @@ -3,7 +3,7 @@

{% if compound.templates != None %}
{% set j = joiner(', ') %} - template<{% for t in compound.templates %}{{ j() }}{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}{% endfor %}> + template <{% for t in compound.templates %}{{ j() }}{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}{% endfor %}>
{% endif %} enum {% if enum.is_strong %}class {% endif %}{{ prefix }}{{ enum.name }}{% if enum.type %}: {{ enum.type }}{% endif %}{% if enum.is_protected %} protected{% endif %}{% if enum.since %} {{ enum.since }}{% endif %} diff --git a/src/poxy/mcss/documentation/templates/doxygen/details-func.html b/src/poxy/mcss/documentation/templates/doxygen/details-func.html index 1e6e293..170511e 100644 --- a/src/poxy/mcss/documentation/templates/doxygen/details-func.html +++ b/src/poxy/mcss/documentation/templates/doxygen/details-func.html @@ -7,19 +7,19 @@

{% if compound.templates != None %} {% set j = joiner(', ') %} - template<{% for t in compound.templates %}{{ j() }}{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}{% endfor %}> + template <{% for t in compound.templates %}{{ j() }}{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}{% endfor %}> {% endif %} {% if compound.templates != None and func.templates != None %}
{% endif %} {% if func.templates != None %} {% set j = joiner(', ') %} - template<{% for t in func.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}> + template <{% for t in func.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}> {% endif %}
{% endif %} {% set j = joiner(',\n ') %} - {{ func.prefix }}{{ func.type }} {{ prefix }}{{ func.name }}({% for param in func.params %}{{ j() }}{{ param.type_name }}{% if param.default %} = {{ param.default }}{% endif %}{% endfor %}){{ func.suffix }}{% if func.is_explicit %} explicit {% endif %}{% if func.is_final %} final{% elif func.is_override %} override{% elif func.is_pure_virtual %} pure virtual{% elif func.is_virtual %} virtual{% endif %}{% if func.is_protected %} protected{% if func.is_slot %} slot{% endif %}{% elif func.is_private %} private{% if func.is_slot %} slot{% endif %}{% elif func.is_signal %} signal{% elif func.is_slot %} public slot{% endif %}{% if func.is_defaulted %} defaulted{% endif %}{% if func.is_deleted %} deleted{% endif %}{% if func.is_consteval %} consteval{% elif func.is_constexpr %} constexpr{% endif %}{% if func.is_conditional_noexcept %} noexcept(…){% elif func.is_noexcept %} noexcept{% endif %}{% if func.since %} {{ func.since }}{% endif %} + {{ func.prefix }}{{ func.type }} {{ prefix }}{{ func.name }}({% for param in func.params %}{{ j() }}{{ param.type_name }}{% if param.default %} = {{ param.default }}{% endif %}{% endfor %}){{ func.suffix }}{% if func.is_explicit %} explicit {% endif %}{% if func.is_final %} final{% elif func.is_override %} override{% elif func.is_pure_virtual %} pure virtual{% elif func.is_virtual %} virtual{% endif %}{% if func.is_protected %} protected{% if func.is_slot %} slot{% endif %}{% elif func.is_private %} private{% if func.is_slot %} slot{% endif %}{% elif func.is_signal %} signal{% elif func.is_slot %} public slot{% endif %}{% if func.is_defaulted %} defaulted{% endif %}{% if func.is_deleted %} deleted{% endif %}{% if func.is_consteval %} consteval{% elif func.is_constexpr %} constexpr{% endif %}{% if func.is_conditional_noexcept %} noexcept(…){% elif func.is_noexcept %} noexcept{% endif %}{% if func.since %} {{ func.since }}{% endif %} {% if func.include and compound.templates == None and func.templates == None %} {% endif %} diff --git a/src/poxy/mcss/documentation/templates/doxygen/details-typedef.html b/src/poxy/mcss/documentation/templates/doxygen/details-typedef.html index 184eeb0..b042af9 100644 --- a/src/poxy/mcss/documentation/templates/doxygen/details-typedef.html +++ b/src/poxy/mcss/documentation/templates/doxygen/details-typedef.html @@ -7,14 +7,14 @@

{% if compound.templates != None %} {% set j = joiner(', ') %} - template<{% for t in compound.templates %}{{ j() }}{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}{% endfor %}> + template <{% for t in compound.templates %}{{ j() }}{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}{% endfor %}> {% endif %} {% if compound.templates != None and typedef.templates != None %}
{% endif %} {% if typedef.templates != None %} {% set j = joiner(', ') %} - template<{% for t in typedef.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}> + template <{% for t in typedef.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}> {% endif %}
{% endif %} diff --git a/src/poxy/mcss/documentation/templates/doxygen/details-var.html b/src/poxy/mcss/documentation/templates/doxygen/details-var.html index c4b82ef..ec78ad0 100644 --- a/src/poxy/mcss/documentation/templates/doxygen/details-var.html +++ b/src/poxy/mcss/documentation/templates/doxygen/details-var.html @@ -7,14 +7,14 @@

{% if compound.templates != None %} {% set j = joiner(', ') %} - template<{% for t in compound.templates %}{{ j() }}{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}{% endfor %}> + template <{% for t in compound.templates %}{{ j() }}{{ t.type }} {% if t.name %}{{ t.name }}{% else %}_{{ loop.index }}{% endif %}{% endfor %}> {% endif %} {% if compound.templates != None and var.templates != None %}
{% endif %} {% if var.templates != None %} {% set j = joiner(', ') %} - template<{% for t in var.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}> + template <{% for t in var.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}> {% endif %}
{% endif %} diff --git a/src/poxy/mcss/documentation/templates/doxygen/entry-class.html b/src/poxy/mcss/documentation/templates/doxygen/entry-class.html index 29aff22..54aac47 100644 --- a/src/poxy/mcss/documentation/templates/doxygen/entry-class.html +++ b/src/poxy/mcss/documentation/templates/doxygen/entry-class.html @@ -1,7 +1,7 @@
{% if class.templates != None %} {% set j = joiner(', ') %} -
template<{% for t in class.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}>
+
template <{% for t in class.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}>
{% endif %} {{ class.kind }} {{ class.name }}{% if class.is_protected %} protected{% endif %}{% if class.is_final %} final{% elif class.is_virtual %} virtual{% endif %}{% if class.deprecated %} {{ class.deprecated }}{% endif %}{% if class.since %} {{ class.since }}{% endif %} diff --git a/src/poxy/mcss/documentation/templates/doxygen/entry-concept.html b/src/poxy/mcss/documentation/templates/doxygen/entry-concept.html index 3b67020..1921e5b 100644 --- a/src/poxy/mcss/documentation/templates/doxygen/entry-concept.html +++ b/src/poxy/mcss/documentation/templates/doxygen/entry-concept.html @@ -1,7 +1,7 @@
{% if concept.templates != None %} {% set j = joiner(', ') %} -
template<{% for t in concept.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}>
+
template <{% for t in concept.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}>
{% endif %} {{ concept.kind }} {{ concept.name }}{% if concept.is_protected %} protected{% endif %}{% if concept.deprecated %} {{ concept.deprecated }}{% endif %}{% if concept.since %} {{ concept.since }}{% endif %} diff --git a/src/poxy/mcss/documentation/templates/doxygen/entry-func.html b/src/poxy/mcss/documentation/templates/doxygen/entry-func.html index 8627c0f..4b21b61 100644 --- a/src/poxy/mcss/documentation/templates/doxygen/entry-func.html +++ b/src/poxy/mcss/documentation/templates/doxygen/entry-func.html @@ -1,7 +1,7 @@ {% if func.templates != None %} {% set j = joiner(', ') %} -
template<{% for t in func.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}>
+
template <{% for t in func.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}>
{% endif %} {% set j = joiner(',\n ') %} {{ func.prefix }}{% if func.type == 'void' %}void {% elif func.type %}auto {% endif %}{{ func.name }}({% for param in func.params %}{{ j() }}{{ param.type_name }}{% if param.default %} = {{ param.default }}{% endif %}{% endfor %}){{ func.suffix }}{% if func.type and func.type != 'void' %} -> {{ func.type }}{% endif %}{% if func.deprecated %} {{ func.deprecated }}{% endif %}{% if not func.type or mark_nonpublic %}{% if func.is_protected %} protected{% if func.is_slot %} slot{% endif %}{% elif func.is_private %} private{% if func.is_slot %} slot{% endif %}{% elif func.is_signal %} signal{% elif func.is_slot %} public slot{% endif %}{% endif %}{% if func.is_defaulted %} defaulted{% endif %}{% if func.is_deleted %} deleted{% endif %}{% if func.is_explicit %} explicit {% endif %}{% if func.is_final %} final{% elif func.is_override %} override{% elif func.is_pure_virtual %} pure virtual{% elif func.is_virtual %} virtual{% endif %}{% if func.is_consteval %} consteval{% elif func.is_constexpr %} constexpr{% endif %}{% if func.is_conditional_noexcept %} noexcept(…){% elif func.is_noexcept %} noexcept{% endif %}{% if func.since %} {{ func.since }}{% endif %} diff --git a/src/poxy/mcss/documentation/templates/doxygen/entry-typedef.html b/src/poxy/mcss/documentation/templates/doxygen/entry-typedef.html index 22a7a1a..9e02a6a 100644 --- a/src/poxy/mcss/documentation/templates/doxygen/entry-typedef.html +++ b/src/poxy/mcss/documentation/templates/doxygen/entry-typedef.html @@ -1,7 +1,7 @@ {% if typedef.templates != None %} {% set j = joiner(', ') %} -
template<{% for t in typedef.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif%}{% endfor %}>
+
template <{% for t in typedef.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif%}{% endfor %}>
{% endif %} using {{ typedef.name }} = {{ typedef.type }}{{ typedef.args }}{% if typedef.deprecated %} {{ typedef.deprecated }}{% endif %}{% if mark_nonpublic and typedef.is_protected %} protected{% endif %}{% if typedef.since %} {{ typedef.since }}{% endif %} {# This empty line needs to be there otherwise it's eaten #} diff --git a/src/poxy/mcss/documentation/templates/doxygen/entry-var.html b/src/poxy/mcss/documentation/templates/doxygen/entry-var.html index 52f21d4..6dd45d8 100644 --- a/src/poxy/mcss/documentation/templates/doxygen/entry-var.html +++ b/src/poxy/mcss/documentation/templates/doxygen/entry-var.html @@ -1,7 +1,7 @@ {% if var.templates != None %} {% set j = joiner(', ') %} -
template<{% for t in var.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif%}{% endfor %}>
+
template <{% for t in var.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif%}{% endfor %}>
{% endif %} {%+ if var.is_static %}static {% endif %}{{ var.type }} {{ var.name }}{% if var.deprecated %} {{ var.deprecated }}{% endif %}{% if mark_nonpublic and var.is_protected %} protected{% endif %}{% if var.is_constexpr %} constexpr{% endif %}{% if var.since %} {{ var.since }}{% endif %} {# This empty line needs to be there otherwise it's eaten #} diff --git a/src/poxy/run.py b/src/poxy/run.py index 0e0991e..b616d87 100644 --- a/src/poxy/run.py +++ b/src/poxy/run.py @@ -1443,6 +1443,7 @@ def postprocess_html(context: Context): fixers.InjectSVGs(), fixers.InstallSearchShim(), fixers.DeducedAutoReturnType(), + fixers.RemoveTemplateNoise(), ) threads = min(len(files), context.threads, 16) diff --git a/src/poxy/version.txt b/src/poxy/version.txt index 288adf5..dffa40e 100644 --- a/src/poxy/version.txt +++ b/src/poxy/version.txt @@ -1 +1 @@ -0.13.3 +0.13.4