Skip to content

GH-110417: Fix glob docs ordering #110418

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 4 commits into from
Nov 13, 2023

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented Oct 5, 2023

Fix placement of translate() docs.

Move "see also: pathlib" admonition to the bottom of the page, alongside one for fnmatch. This helps the module introduction flow more naturally into the function descriptions.

Add an "Examples" subheading just before the examples. This makes it more obvious that examples aren't specifically related to the preceding documentation of escape().


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

Move examples of `glob()` usage into the `.. function:: glob()` block, and
move the mention of `fnmatch` to just before the mention of `pathlib`.

As a result, the description and examples of `glob()` are not interrupted
by descriptions of `iglob()` and `escape()`.
@barneygale
Copy link
Contributor Author

Maybe the "See also" bits would be better at the end? Hm.

Copy link
Member

@ezio-melotti ezio-melotti left a comment

Choose a reason for hiding this comment

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

I'm not sure I agree with this reordering. Having the examples at the bottom of the page is a common pattern used by several other pages, however most other pages are a bit more structured, with clear headers to separate different sections.

In this case, even thought the examples only use glob, they might as well work for iglob (and I think this was the original intent, before the addition of escape). If someone follows a direct link to iglob, they might miss these examples now that they are in glob. On the other hand, someone reading glob docs might not notice that there are examples at the bottom (this is a side-effect of having examples at the bottom of the page).

Since this specific page is quite short, I think it might be ok to leave the examples at the bottom, and add headers to make the sections stand out more. Adding links to the examples within the function description is probably not necessary.

By doing this we can also maintain a diataxian separation of the 3 different parts:

  • the initial description (explanation)
  • the list of functions (reference)
  • the examples (howto)

@erlend-aasland
Copy link
Contributor

Since this specific page is quite short, I think it might be ok to leave the examples at the bottom, and add headers to make the sections stand out more. Adding links to the examples within the function description is probably not necessary.

I think this is a good idea. You can link to the examples (or how-tos, or guides ...) from the reference. OTOH, it is ok to include short examples in the reference, iff they are specific to the API they are describing.

@gvanrossum
Copy link
Member

Thank you!

@barneygale
Copy link
Contributor Author

barneygale commented Oct 13, 2023

Thank you very much for the explanation and pointers @ezio-melotti and @erlend-aasland! I think I understand now.

I've revised the PR so that the examples stay put. Instead:

  • The "see also: pathlib" bit is moved to the end (alongside "see also: fnmatch")
  • The function definitions are introduced by a "This module defines these functions:" sentence, which seems to be a common formulation in other module docs. Perhaps this is pointless; happy to take it out.
  • The examples are preceded by a new "Examples" subheading, and the introductory wording very slightly revised.

I couldn't really find other examples of a simple "Functions" subheading. Do you think the "Examples" subheading alone works? I think it reads pretty well now: https://cpython-previews--110418.org.readthedocs.build/en/110418/library/glob.html

Also happy to withdraw this PR entirely if we think there's nothing worth doing here.

@barneygale barneygale changed the title GH-110417: Improve ordering of info in glob docs GH-110417: Minor tweaks to glob docs Oct 13, 2023
@barneygale barneygale removed needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Nov 13, 2023
@barneygale barneygale changed the title GH-110417: Minor tweaks to glob docs GH-110417: Fix glob docs ordering Nov 13, 2023
@barneygale barneygale enabled auto-merge (squash) November 13, 2023 17:43
@barneygale barneygale merged commit d5491a6 into python:main Nov 13, 2023
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Fix incorrect placement of `translate()` docs from cf67ebf.

Move "see also: pathlib" admonition to the bottom of the page, alongside one for fnmatch. This helps the module introduction flow more naturally into the function descriptions.

Add an "Examples" subheading just before the examples. This makes it more obvious that examples aren't specifically related to the preceding documentation of `escape()` and `translate()`.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Fix incorrect placement of `translate()` docs from cf67ebf.

Move "see also: pathlib" admonition to the bottom of the page, alongside one for fnmatch. This helps the module introduction flow more naturally into the function descriptions.

Add an "Examples" subheading just before the examples. This makes it more obvious that examples aren't specifically related to the preceding documentation of `escape()` and `translate()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants