Skip to content

Docs: a start on an 'improve this page' feature #136246

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

nedbat
Copy link
Member

@nedbat nedbat commented Jul 3, 2025

At the Docs WG meeting, we talked about smoothing the path for people to suggest improvements to the docs. This is a start. It uses more JavaScript than we are used to.

I haven't done anything to trim down the "Report a bug" page. Ideas welcome.


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

@nedbat nedbat force-pushed the nedbat/improve-docs-page branch from b8f50bc to 673e347 Compare July 3, 2025 14:57
Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

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

This looks great. I have some little thoughts.

Also, this should probably get an issue and blurb?


- You can start a discussion about the page on the Python discussion forum.
This link will start a pre-populated topic:
`Question about "PAGETITLE" <https://discuss.python.org/new-topic?category=documentation&title=Question+about+%22PAGETITLE%22&body=About+the+page+at+PAGEURL%3A>`_.
Copy link
Member

Choose a reason for hiding this comment

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

I think we should use the path here, as otherwise it can be ambiguous, e.g. there are several Introduction in the docs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Try the live version in the preview build. The body gets populated with the URL.

Copy link
Member

Choose a reason for hiding this comment

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

I see, the issue one however does not work for me, it sends me to the choose a template page. I also think good titles would be nice for triage/finding purposes.

Copy link
Member Author

Choose a reason for hiding this comment

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

It populates an issue for me, what are other people seeing?

Copy link
Member

Choose a reason for hiding this comment

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

I mean, when one opens an issue for a page like so where there are several pages with the same title, the issue title is then very ambiguous (e.g. in the above case, just „Introduction”).

Copy link
Contributor

Choose a reason for hiding this comment

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

The title will be simple but the body contains the URL, which is will be unambiguous. If the title is "Question about 'Introduction'" and then the body contains a link like https://cpython-previews--136246.org.readthedocs.build/en/136246/c-api/intro.html I think people will be able to discuss the correct page.

`Docs: problem with "PAGETITLE" <https://github.com/python/cpython/issues/new?title=Docs%3A+problem+with+%22PAGETITLE%22&labels=docs&body=The+page+at+PAGEURL+has+a+problem%3A>`_.

- You can `edit the page on GitHub <https://github.com/python/cpython/blob/main/Doc/PAGESOURCE?plain=1>`_
and open a pull request, though you will need to have signed a contributor agreement before it can be merged.
Copy link
Member

Choose a reason for hiding this comment

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

Just a little note, I think mentioning the contribution agreement here may scare away people, as it does not explain much about it, and does not pop up when they edit the page.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I was torn about putting it here, we can drop it if needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it to "open a pull request and begin the contribution process." to at least hint at the idea that there will be steps needed.

@ryan-duve
Copy link
Contributor

I like the "This link will start a pre-populated topic:" link, but I wonder whether "less is more" applies here. In particular, I mean if the "Improve this page" link directly goes to the pre-populated Discourse form, would that more directly get users to where they can make a suggestion? If so, would it be better for "Improve this page" to link straight to Discourse?

@nedbat
Copy link
Member Author

nedbat commented Jul 4, 2025

I like the "This link will start a pre-populated topic:" link, but I wonder whether "less is more" applies here. In particular, I mean if the "Improve this page" link directly goes to the pre-populated Discourse form, would that more directly get users to where they can make a suggestion? If so, would it be better for "Improve this page" to link straight to Discourse?

I'm not sure Discourse is the right place for everyone. Some people will have edits, some will have questions, some will want to discuss ideas for improvement. I appreciate the desire to make the path as well-greased as possible. If we do decide to link straight to Discourse, we'll need to change the link from "Improve this page", because Discourse is not the place to do that directly.

<li>
<a href="https://github.com/python/cpython/blob/main/Doc/{{ sourcename|replace('.rst.txt', '.rst') }}"
<a href="https://github.com/python/cpython/blob/main/Doc/{{ sourcename|replace('.rst.txt', '.rst?plain=1') }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<a href="https://github.com/python/cpython/blob/main/Doc/{{ sourcename|replace('.rst.txt', '.rst?plain=1') }}"
<a href="https://github.com/python/cpython/blob/main/Doc/{{ pagename }}.rst?plain=1"

Simplification suggestion; reference

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@nedbat nedbat marked this pull request as ready for review August 2, 2025 11:37
@nedbat nedbat requested review from AA-Turner and hugovk as code owners August 2, 2025 11:37
Copy link
Member

Choose a reason for hiding this comment

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

Let's rename to improve-page.rst (similar to other files)

Copy link
Member

Choose a reason for hiding this comment

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

Or e.g. suggest-improvement.rst?

Copy link
Member Author

Choose a reason for hiding this comment

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

improve-page.rst

Comment on lines 25 to 26
You were reading "PAGETITLE" at `<PAGEURL>`_. The source for that page is on
`GitHub <https://github.com/python/cpython/blob/main/Doc/PAGESOURCE?plain=1>`_.
Copy link
Member

Choose a reason for hiding this comment

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

If I do something like:

Should we:

  • Fix the links for the "Improve a documentation page"?
  • Fix the titles so it still refers to the tutorial?
  • Remove "Improve this page" from this page?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've fixed this.

<div role="note" aria-label="source link">
<h3>{{ _('This page') }}</h3>
<ul class="this-page-menu">
<li><a href="{{ pathto('bugs') }}">{% trans %}Report a bug{% endtrans %}</a></li>
<li><a class="improvepage" href="{{ pathto('improvepage') }}?pageurl=https://docs.python.org/3/{{ pagename }}.html&pagesource={{ sourcename|replace('.rst.txt', '.rst') }}">{% trans %}Improve this page{% endtrans %}</a></li>
Copy link
Member

Choose a reason for hiding this comment

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

This hardcodes /3/.

What happens if I'm reading the 3.14 docs? Or the Spanish translation?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've fixed this to use the actual full URL of the original page.

Comment on lines 13 to 21
<script>
document.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(window.location.search);
document.body.innerHTML = document.body.innerHTML
.replace(/PAGETITLE/g, params.get('pagetitle'))
.replace(/PAGEURL/g, params.get('pageurl'))
.replace(/PAGESOURCE/g, params.get('pagesource'));
});
</script>
Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid inline JS? Ideally both here and the <script> in the template would be moved to .js files.

Copy link
Member Author

Choose a reason for hiding this comment

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

There are already two instances of inline script, and tbh, for small one-off chunks like this it might be more understandable to have them on the page where they are used. But in any case, would it be OK to land this feature first and then decide on centralization?

Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

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

I'd like to see if we can make this work as far as reasonably practical without JS -- we currently don't require users to have JS enabled to use the documentation.

On Hugo's point on translations, we could add another .. only:: block for non-English containing a brief description of changes to the translation vs source content.

A

@StanFromIreland
Copy link
Member

StanFromIreland commented Aug 2, 2025

On Hugo's point on translations, we could add another .. only:: block for non-English containing a brief description of changes to the translation vs source content.

For reference, the current practice for bugs.po, per PEP 545, is to stick it in somewhere at the end of an existing message.

I’m not a Sphinx expert but I don’t see how it would work, from my experience it can only exclude builders. If you could please share some Sphinx magic I’d love to open a PR for bugs.

@nedbat
Copy link
Member Author

nedbat commented Aug 2, 2025

I'd like to see if we can make this work as far as reasonably practical without JS -- we currently don't require users to have JS enabled to use the documentation.

I'm happy to try another approach, but I'm not sure what we can do. The goal is for the Improve page to know what page the user was reading. Do you have another way?

nedbat added 2 commits August 2, 2025 16:20
- use the actual page URL
- tighten the wording
@nedbat
Copy link
Member Author

nedbat commented Aug 2, 2025

On Hugo's point on translations, we could add another .. only:: block for non-English containing a brief description of changes to the translation vs source content.

For reference, the current practice for bugs.po, per PEP 545, is to stick it in somewhere at the end of an existing message.

I’m not a Sphinx expert but I don’t see how it would work, from my experience it can only exclude builders. If you could please share some Sphinx magic I’d love to open a PR for bugs.

Maybe I don't understand the translation issue. What is the .. only:: block for?

@nedbat nedbat removed the skip news label Aug 2, 2025
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.

6 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy