Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Doc/improve-page-nojs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
:orphan:

****************************
Improve a documentation page
****************************

.. only:: html and not epub

We are always interested to hear ideas about improvements to the documentation.

.. only:: translation

If the bug or suggested improvement concerns the translation of this
documentation, open an issue or edit the page in
`translation's repository <TRANSLATION_REPO_>`_ instead.

You have a few ways to ask questions or suggest changes:

- You can start a discussion about the page on the Python discussion forum.
This link will start a topic in the Documentation category:
`New Documentation topic <https://discuss.python.org/new-topic?category=documentation>`_.

- You can open an issue on the Python GitHub issue tracker. This link will
create a new issue with the "docs" label:
`New docs issue <https://github.com/python/cpython/issues/new?labels=docs>`_.
Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland Feb 13, 2026

Choose a reason for hiding this comment

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

I think this (specifically labels=docs) link won't work for anyone who doesn’t have triage permissions in CPython (otherwise, spammers could create "triaged" issues), I suggest linking to the template instead, i.e.: https://github.com/python/cpython/issues/new?template=documentation.yml

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.

Here the template is a better choice, I'll change it.

43 changes: 43 additions & 0 deletions Doc/improve-page.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
:orphan:

****************************
Improve a documentation page
****************************

.. only:: html and not epub

.. raw:: html

<script>
document.addEventListener('DOMContentLoaded', () => {
const params = new URLSearchParams(window.location.search);
document.body.innerHTML = document.body.innerHTML
Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland Feb 12, 2026

Choose a reason for hiding this comment

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

This is vulnerable to a DOM based XSS, no? We should escape the params.

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.

Excellent point, and I should have known better. I will fix 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.

Done.

.replace(/PAGETITLE/g, params.get('pagetitle'))
.replace(/PAGEURL/g, params.get('pageurl'))
.replace(/PAGESOURCE/g, params.get('pagesource'));
});
</script>

We are always interested to hear ideas about improvements to the documentation.

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>`_.

Comment thread
nedbat marked this conversation as resolved.
.. only:: translation

If the bug or suggested improvement concerns the translation of this
documentation, open an issue or edit the page in
`translation's repository <TRANSLATION_REPO_>`_ instead.

You have a few ways to ask questions or suggest changes:

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

- You can open an issue on the Python GitHub issue tracker. This link will
create a new pre-populated issue:
`Docs: problem with page "PAGETITLE" <https://github.com/python/cpython/issues/new?title=Docs%3A+problem+with+page+%22PAGETITLE%22&labels=docs&body=The+page+at+PAGEURL+has+a+problem%3A>`_.
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.

Similarly to above,

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

I expect this will also require updating body.

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 URL works to create the title and body, but does not apply the label, as tested here: #144780. I think this is fine.


- You can `edit the page on GitHub <https://github.com/python/cpython/blob/main/Doc/PAGESOURCE?plain=1>`_
to open a pull request and begin the contribution process.
17 changes: 16 additions & 1 deletion Doc/tools/templates/customsourcelink.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
{%- if show_source and has_source and sourcename %}
<script>
document.addEventListener('DOMContentLoaded', () => {
const title = document.querySelector('meta[property="og:title"]').content;
const elements = document.querySelectorAll('.improvepage');
const pageurl = window.location.href.split('?')[0];
elements.forEach(element => {
const url = new URL(element.href.split('?')[0].replace("-nojs", ""));
url.searchParams.set('pagetitle', title);
url.searchParams.set('pageurl', pageurl);
url.searchParams.set('pagesource', "{{ pagename }}.rst");
element.href = url.toString();
});
});
</script>
<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>
Comment thread
StanFromIreland marked this conversation as resolved.
<li><a class="improvepage" href="{{ pathto('improve-page-nojs') }}">{% trans %}Improve this page{% endtrans %}</a></li>
<li>
<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"
rel="nofollow">{{ _('Show source') }}
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
A new "Improve this page" link is available in the left-hand sidebar of the
docs, offering links to create GitHub issues, discussion forum posts, or
pull requests.
Loading