Skip to content

Docs: remove link elements in builders other than HTML #133720

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

Merged
merged 2 commits into from
May 14, 2025

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant

Conversation

m-aciek
Copy link
Contributor

@m-aciek m-aciek commented May 8, 2025

Follow-up for #132220 (comment)). This change fixes EPUB builds. epubcheck after this change results in 25 fewer errors. Could we please backport it for supported versions?

Before:

% uvx epubcheck 2>&1 >/dev/null | grep 'FATAL'
FATAL - RSC-016 - Python.epub/about.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/bugs.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/abstract.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/allocation.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/apiabiversion.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/arg.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/bool.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/buffer.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/bytearray.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/bytes.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/call.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/capsule.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/cell.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/code.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/codec.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/complex.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/concrete.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/c-api/contextvars.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/contents.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/copyright.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/download.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/glossary.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/index.xhtml:26:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/license.xhtml:27:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".
FATAL - RSC-016 - Python.epub/py-modindex.xhtml:29:5 - Fatal Error while parsing file: The element type "link" must be terminated by the matching end-tag "</link>".

After:


📚 Documentation preview 📚: https://cpython-previews--133720.org.readthedocs.build/

@merwok merwok added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels May 9, 2025
@merwok

This comment was marked as outdated.

@hugovk
Copy link
Member

hugovk commented May 12, 2025

We have three conditionals in a row (extra whitespace for clarity):

    {% if builder == "html" and enable_analytics %}
      <script defer data-domain="docs.python.org" src="https://analytics.python.org/js/script.outbound-links.js"></script>
    {% endif %}
 
   {% if builder == "html" %}<link rel="canonical" href="https://docs.python.org/3/{{pagename}}.html">{% endif %}
 
   {% if builder != "htmlhelp" %}
      {% if pagename == 'whatsnew/changelog' and not embedded %}
      <script type="text/javascript" src="{{ pathto('_static/changelog_search.js', 1) }}"></script>{% endif %}
    {% endif %}

Should that last if builder != "htmlhelp" also be if builder == "html"?

If so, shall we factor that check out? Something along the lines of:

    {% if builder == "html" %}

      {% if enable_analytics %}
        <script defer data-domain="docs.python.org" src="https://analytics.python.org/js/script.outbound-links.js"></script>
      {% endif %}

      <link rel="canonical" href="https://docs.python.org/3/{{pagename}}.html">
 
      {% if pagename == 'whatsnew/changelog' and not embedded %}
      <script type="text/javascript" src="{{ pathto('_static/changelog_search.js', 1) }}"></script>{% endif %}

    {% endif %}

@merwok
Copy link
Member

merwok commented May 13, 2025

@Yhg1s this fixes a bug in docs epub build; would it be acceptable for backport to 3.12 ?

@Yhg1s
Copy link
Member

Yhg1s commented May 13, 2025

Yeah, backporting to 3.12 is fine.

@merwok merwok added the needs backport to 3.12 only security fixes label May 13, 2025
@merwok merwok merged commit 0afbd4e into python:main May 14, 2025
24 checks passed
@miss-islington-app
Copy link

Thanks @merwok for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 14, 2025
Fixes epub build
(cherry picked from commit 0afbd4e)

Co-authored-by: Maciej Olko <maciej.olko@affirm.com>
@bedevere-app
Copy link

bedevere-app bot commented May 14, 2025

3.14 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 14, 2025
Fixes epub build
(cherry picked from commit 0afbd4e)

Co-authored-by: Maciej Olko <maciej.olko@affirm.com>
@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label May 14, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 14, 2025
Fixes epub build
(cherry picked from commit 0afbd4e)

Co-authored-by: Maciej Olko <maciej.olko@affirm.com>
@bedevere-app
Copy link

bedevere-app bot commented May 14, 2025

3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label May 14, 2025
@bedevere-app
Copy link

bedevere-app bot commented May 14, 2025

3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label May 14, 2025
hugovk pushed a commit that referenced this pull request May 14, 2025
#134005)

Co-authored-by: Maciej Olko <maciej.olko@affirm.com>
hugovk pushed a commit that referenced this pull request May 14, 2025
#134006)

Co-authored-by: Maciej Olko <maciej.olko@affirm.com>
hugovk pushed a commit that referenced this pull request May 14, 2025
#134007)

Co-authored-by: Maciej Olko <maciej.olko@affirm.com>
@python python deleted a comment May 15, 2025
@m-aciek m-aciek deleted the doc-epub-fix-head branch May 15, 2025 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant

5 participants

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant