Skip to content

Docs: split builtins to their own page from library - #156682

Open
nedbat wants to merge 20 commits into
python:mainfrom
nedbat:nedbat/split-builtin-stdlib
Open

Docs: split builtins to their own page from library#156682
nedbat wants to merge 20 commits into
python:mainfrom
nedbat:nedbat/split-builtin-stdlib

Conversation

@nedbat

@nedbat nedbat commented Aug 30, 2026

Copy link
Copy Markdown
Member

We've talked about separating the built-ins from the stdlib modules, since "dict" (for example) isn't part of the stdlib.

I think I took care of all the places the pages are referenced, but the non-HTML builds are new to me, so I might have missed something.

I tried to make the intro paragraphs and pages useful, and avoided over-editing them.

@nedbat

nedbat commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

Also: is this NEWS-worthy?

@StanFromIreland

Copy link
Copy Markdown
Member

Also: is this NEWS-worthy?

I don't see a need for one here, I think the docs speak for themselves.

@read-the-docs-community

read-the-docs-community Bot commented Aug 30, 2026

Copy link
Copy Markdown

Comment thread Doc/tools/templates/indexcontent.html Outdated
Comment thread Doc/library/builtin-index.rst Outdated
Comment thread Doc/library/index.rst
Comment thread Doc/library/builtin-index.rst Outdated

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shall we name the new Doc/library/builtin-index.rst as Doc/builtins/index.rst instead?

Then instead of:

We get a neater:

This PR can still reference the builtin stuff in their current location, and a followup could move the relevant files and deal with redirects:

  • Doc/library/functions.rst -> Doc/builtins/functions.rst
  • Doc/library/stdtypes.rst -> Doc/builtins/stdtypes.rst
  • Doc/library/constants.rst -> Doc/builtins/constants.rst
  • Doc/library/exceptions.rst -> Doc/builtins/exceptions.rst
  • Doc/library/threadsafety.rst -> Doc/builtins/threadsafety.rst
  • Doc/library/time-complexity.rst -> Doc/builtins/time-complexity.rst

Comment thread Doc/library/builtin-index.rst Outdated
Comment thread Doc/library/builtin-index.rst Outdated
Comment thread Doc/library/intro.rst Outdated
Comment thread Doc/library/index.rst Outdated
Comment thread Doc/library/intro.rst Outdated
Comment thread Doc/tools/templates/indexcontent.html Outdated
Comment thread Doc/library/builtin-index.rst Outdated
Comment thread Doc/library/builtin-index.rst Outdated

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, you need to update the What Now? page in the tutorial.

I concur with Hugo, splitting this into a separate directory would be nicer. We can do redirects at client side (using one of the various Sphinx extensions) or sever side (by configuring them in python/psf-salt).

Comment thread Doc/reference/index.rst Outdated
@nedbat

nedbat commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

I can do the renames and redirects.

We can do redirects at client side (using one of the various Sphinx extensions) or sever side (by configuring them in python/psf-salt).

What Sphinx extension have we used for redirects before? I see https://github.com/python/psf-salt/blob/main/salt/docs/config/nginx.docs-redirects.conf for the psf-salt approach.

@StanFromIreland

Copy link
Copy Markdown
Member

What Sphinx extension have we used for redirects before?

We use sphinxext-rediraffe in the Devguide, it generates stubs with some JS to redirect to the new page.

@nedbat

nedbat commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

What Sphinx extension have we used for redirects before?

We use sphinxext-rediraffe in the Devguide, it generates stubs with some JS to redirect to the new page.

I knew rediraffe was somewhere! Is there a reason we don't want to introduce it for the main docs?

@StanFromIreland

Copy link
Copy Markdown
Member

Is there a reason we don't want to introduce it for the main docs?

I presume it's simply because there hasn't really been a need so far. We're less keen to move pages here than in the Devguide. IIRC rediraffe requires JS, but that ship has sailed anyway.

@hugovk

hugovk commented Sep 1, 2026

Copy link
Copy Markdown
Member

Server-side psf-salt redirects would be better than client-side sphinxext-rediraffe: they work with JavaScript disabled (better for all the scrapers and bots), are faster on server-side (HTTP layer before any HTML fetched), and get cached in the CDN, and better for SEO.

We don't have such server-side control for the devguide, which is hosted on GitHub Pages. (Also I'd say client-side JS redirects are fine for the less-important devguide.)

@nedbat

nedbat commented Sep 1, 2026

Copy link
Copy Markdown
Member Author

That all makes sense. Do we have a way to coordinate the updates to psf-salt with updates to the docs, especially with backports involved?

@StanFromIreland

StanFromIreland commented Sep 1, 2026

Copy link
Copy Markdown
Member

(There's no documented process I'm afraid) You can open a PR there and limit the redirect to specific Python versions. I can review and merge when we land this.

@nedbat nedbat added the docs Documentation in the Doc dir label Sep 1, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Sep 1, 2026
@nedbat
nedbat force-pushed the nedbat/split-builtin-stdlib branch from c6de373 to ea9966e Compare September 1, 2026 17:43
@nedbat

nedbat commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

Moving pages causes the "removed HTML IDs" check to fail. The IDs aren't gone, they are in a different page. Do I still add them to removed-ids.txt?

@StanFromIreland

Copy link
Copy Markdown
Member

Do I still add them to removed-ids.txt?

Yes, see the line with an asyncio file for the required format.

@nedbat
nedbat force-pushed the nedbat/split-builtin-stdlib branch from 65aaf8b to 016ce6b Compare September 10, 2026 22:42
@nedbat

nedbat commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

I think this is done.

@StanFromIreland

Copy link
Copy Markdown
Member

@nedbat can you please avoid force pushing, it makes it a little harder to review. See also the section in the Devguide.

@nedbat

nedbat commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

sorry, a habit from other repos.

Comment thread Doc/library/intro.rst Outdated
learning about random subjects, you choose a random page
and read a section or two. Regardless of the order in which you
read the sections of this manual, it helps to first read
:ref:`built-in-funcs` in :ref:`builtins-index`, as the remainder of this section

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the second link required, if the first one already brings the reader to the right page?

(This reads to me like «Read Section A in Chapter 1», which is needed in books but not hypertext)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed.

Comment thread Doc/library/intro.rst

.. seealso::

Let the show begin!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wasn’t this was harmless and a bit of flair?

@nedbat nedbat Sep 12, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The idea of starting a show was lost once all of the Availability sections were added. It's not clear to me at all that a reader at this point will be feeling like a show is starting. The sentence was a bit of flair, but isn't in the same tone as the rest of the section.

Comment thread Doc/library/intro.rst
browse the table of contents (in front of the manual), or look for a specific
function, module or term in the index (in the back). And finally, if you enjoy
learning about random subjects, you choose a random page number (see module
:mod:`random`) and read a section or two. Regardless of the order in which you

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not keep the random module link as an example of a random page? (and/or maybe a hint about a way to make random decision!)

Not fully sure what the original intent was here, but as we are in Library Reference and not Tutorial I don’t think the link was bad. Can you say why you removed it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For two reasons: first, there are no page numbers the way most people read the docs (on the web). Second, for someone just becoming familiar with the stdlib, dropping them into the random module won't help them select a random page number.

Comment thread Doc/library/intro.rst Outdated
in to the Python interpreter; others are written in Python and imported in
The Python standard library consists of a collection of modules. There are
many ways to dissect this collection. Some modules are written in C and compiled
into the Python interpreter; others are written in Python and imported in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we say that some modules are written in C and compiled to importable modules, or is it confusing at this point?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I see what you mean, there are two dimensions of description here, but only two of the combinations are described. "Compiled into the interpreter" is the less interesting aspect. I've changed it to:

Most modules are written in Python,
but some are written in C. All can be imported into your program to add
functionality.

Comment thread Doc/tools/check-html-ids.py

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall looks good to me, although this will break quite a lot of translations, so please post an announcement in the Translations category of Discourse so that translators can recover them.

Comment thread InternalDocs/parser.md
- If parsing fails completely (no rule succeeds in parsing all the input text), the
PEG parser doesn't have a concept of "where the
[`SyntaxError`](https://docs.python.org/3/library/exceptions.html#SyntaxError) is".
[`SyntaxError`](https://docs.python.org/3/builtins/exceptions.html#SyntaxError) is".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Noting this (and similar */3/builtins/* links) will be 404 until the backports are done.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Would it be better to leave the old URLs and let the redirects handle it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since these are InternalDocs, I think that it's fine for them to be slightly broken for a day or two, and it saves us updating them in the future..

@hugovk hugovk added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 11, 2026

@willingc willingc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall, I like this @nedbat. I flagged a couple of places that rewriting the prose to be more direct may help the reader.

Thanks for doing this.

Comment thread Doc/library/index.rst Outdated
Comment on lines +8 to +9
semantics of the Python language, and :ref:`builtins-index` describes
the built-ins, this library reference manual

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With this addition of built-ins, it makes sense to rewrite this paragraph. I think it would be preferable to order the paragraph more directly:

  1. State that "This library reference manual describes the standard library that is ...distributions."
  2. Simplify the "While..." clause to state directly that the reference index and builtins index.

Comment thread Doc/reference/index.rst Outdated
language. It is terse, but attempts to be exact and complete. The semantics of
non-essential built-in object types and of the built-in functions and modules
are described in :ref:`library-index`. For an informal introduction to the
built-in object types and of the built-in functions and modules

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe "standard library modules"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've rewritten and split these paragraphs, though tbh, we're repeating ourselves by having each section also mention what the other sections are.

@hugovk

hugovk commented Sep 12, 2026

Copy link
Copy Markdown
Member

Merge in main to fix:

      File "/home/runner/work/cpython/cpython/Doc/venv/lib/python3.14/site-packages/sphinx/builders/changes.py", line 61, in write_documents
        ttext = self.typemap[changeset.type]
                ~~~~~~~~~~~~^^^^^^^^^^^^^^^^
    KeyError: 'soft-deprecated'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip issue skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

6 participants