Skip to content
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

Update C domain docs to Sphinx 3 syntax #93738

Closed
AA-Turner opened this issue Jun 11, 2022 · 16 comments
Closed

Update C domain docs to Sphinx 3 syntax #93738

AA-Turner opened this issue Jun 11, 2022 · 16 comments
Assignees
Labels
3.10 only security fixes 3.11 only security fixes 3.12 bugs and security fixes docs Documentation in the Doc dir topic-C-API

Comments

@AA-Turner
Copy link
Member

AA-Turner commented Jun 11, 2022

Sphinx would like to remove support for the pre-v3 C domain syntax. We have confirmed that the Linux kernel is no longer using it, so Python is the only project we are blocked on.

I have a branch where I've done the work, but it is a large number of files affected (~50) and the majority of the C-API documentation. The changes are almost all mechanical search-and-replace, but there are a few where I've had to use judgement.

Questions:

  1. Is this change welcome?
  2. How should I proceed with PRs? One per data type, per file, etc?
  3. I would want to backport these changes to 3.10/3.11 (to allow future docs backports without conflicts), does anybody have objections?
  4. Does anybody have other concerns?

cc: @vstinner @serhiy-storchaka @encukou @erlend-aasland @JelleZijlstra @hugovk (Selection of C-API/documentation people, if I've missed anyone please mention them).

A

Tasks

@AA-Turner AA-Turner added docs Documentation in the Doc dir 3.11 only security fixes 3.10 only security fixes topic-C-API 3.12 bugs and security fixes labels Jun 11, 2022
@AA-Turner AA-Turner self-assigned this Jun 11, 2022
@serhiy-storchaka
Copy link
Member

What directives and roles can be used and what are gone?

  1. Is this change welcome?

We do not have a choice, isn't?

  1. How should I proceed with PRs? One per data type, per file, etc?

Could manual and automatic changes be separated, so intermediate results are still working? Say, first some preparing manual changes, then automatic changes, then final manual changes?

  1. I would want to backport these changes to 3.10/3.11 (to allow future docs backports without conflicts), does anybody have objections?

Do not have objections if systems with 3.10 support Sphinx 3.

@AA-Turner
Copy link
Member Author

What directives and roles can be used and what are gone?

Gone in 3.0-3.2:

Relaxed parsing. In Sphinx 2, a definition like :c:type:`const char*` was OK, but in Sphinx 3 this fails -- it should be a :c:expr:. :c:type:`PyObject*` is currently rendered in the docs with a link only to the "PyObject" part of the role text -- it should change to either having the * outside of the role (:c:type:`PyObject`\*) or being an expression (:c:expr:`PyObject*` ). Places where there are references to groups of functions using the type role are invalid (and currently don't work), these should be replaced with literal syntax (e.g. :c:func:`PyErr_Set\*` ).

New in 3.0-3.2, taken from Sphinx's C domain docs:

Directives:

  • .. c:macro:: name(arg list) (Function style macro variant)
  • .. c:struct:: name
  • .. c:union:: name
  • .. c:enum:: name
  • .. c:enumerator:: name

Cross-referencing roles:

  • :c:var: (alias of both :c:member: and :c:data:)
  • :c:struct:
  • :c:union:
  • :c:enum:
  • :c:enumerator:

Documentation support for anonymous entities (https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#anonymous-entities)

Support for re-printing declarations in a list, e.g. for overviews of interfaces (https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#aliasing-declarations)

Support for inline expresssions (https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#inline-expressions-and-types):

  • :c:expr:
  • :c:texpr: ("text-expression")

Support for documentation-namespaces (https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#namespacing)

A

@hugovk
Copy link
Member

hugovk commented Jun 12, 2022

cc: @vstinner @serhiy-storchaka @encukou @erlend-aasland @JelleZijlstra @hugovk (Selection of C-API/documentation people, if I've missed anyone please mention them).

cc also @JulienPalard

@vstinner
Copy link
Member

If I recall correctly, in 2020, I asked Sphinx to add an option to opt-in for the legacy C syntax. When it was discussed, the problem was that Sphinx supporting the new syntax was not widely available in Linux distributions. I guess that the situation changed and now it's perfectly fine to switch to the new syntax.

Doc/conf.py gives some context and links to bpo-40204:

# bpo-40204: Allow Sphinx 2 syntax in the C domain
c_allow_pre_v3 = True

# bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the
# documentation is built with -W (warnings treated as errors).
c_warn_on_allowed_pre_v3 = False

I would want to backport these changes to 3.10/3.11 (to allow future docs backports without conflicts)

I agree to backport for the reason that you give: make future backports simpler.

@encukou
Copy link
Member

encukou commented Jun 13, 2022

I've looked at the proposed branch. The commits there would make good individual PRs, IMO.
IMO we've now made it clear that documentation discussions live in the Discuss category. Perhaps mention there, and if no one objects, go ahead with PRs.

Some specific points:

Please keep/turn as many of these as possible as/into links. Many times this would just mean checking that the links are generated (and are correct).

AFAIK, Sphinx will parse :c:expr: expressions and linkify any types it finds, so :c:expr:const PyObject* will link to PyObject. If that's right, IMO the :c:type:PyObject* should be changed to expr, which is much easier to type than the ecaped star.
Or is there some disadvantage to :c:expr:?

References to a family of functions (glob patterns) like :c:func:PyArg_Parse\* functions link to the section (especially for PyArg_Parse where not all of them actually use the prefix); other cases could use wording like PyArg_Parse* functions (such as :c:func:PyArg_VaParse)

@AA-Turner
Copy link
Member Author

Created at https://discuss.python.org/t/16500

A

@encukou
Copy link
Member

encukou commented Sep 21, 2022

@AA-Turner, do you still want to do this, or would it be better if someone else took over?

mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
…c:expr:`PyBytesObject*`) (python#97782)

:c:type:`PyBytesObject*` -> :c:expr:`PyBytesObject*`
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
…c:expr:`PyTupleObject*`) (python#97780)

:c:type:`PyTupleObject*` -> :c:expr:`PyTupleObject*`
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
…` -> :c:expr:`PyInterpreterState *`) (python#97777)

:c:type:`PyInterpreterState *` -> :c:expr:`PyInterpreterState *`
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
…:`PyObject`) (python#97776)

:c:type:`PyObject` -> :c:expr:`PyObject`
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
…r:`view->obj`) (python#97773)

:c:data:`view->obj` -> :c:expr:`view->obj`
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
…ases) (python#97775)

* :c:type: to :c:expr:

* Update Doc/whatsnew/2.4.rst
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
…:expr:`PyTypeObject*`) (python#97778)

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
…C type>) (python#97768)

:c:type:`<C type>` -> :c:expr:`<C type>`

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
Also, disable using invalid sphinx-lint 0.6.2.
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…97976)

Also, disable using invalid sphinx-lint 0.6.2.
(cherry picked from commit f612565)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…<C type>) (GH-97768) (#97924)

:c:type:`<C type>` -> :c:expr:`<C type>`

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 0031e62)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…teral markup) (GH-97774) (#97910)

(cherry picked from commit 0e72606)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…c:expr:`PyTypeObject*`) (GH-97778) (#97892)

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
(cherry picked from commit c70c8b6)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…97869)

Use `c:struct`
(cherry picked from commit a0f5599)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…cases) (GH-97775) (#97873)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…r:`PyObject`) (GH-97776) (#97889)

:c:type:`PyObject` -> :c:expr:`PyObject`
(cherry picked from commit 0bf6a61)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…pr:`view->obj`) (GH-97773) (#97867)

:c:data:`view->obj` -> :c:expr:`view->obj`
(cherry picked from commit fa59bda)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…*` -> :c:expr:`PyInterpreterState *`) (GH-97777) (#97865)

:c:type:`PyInterpreterState *` -> :c:expr:`PyInterpreterState *`
(cherry picked from commit 4ebb025)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…YPE`) (GH-97770) (#97874)

:c:type:`TYPE` -> :c:expr:`TYPE`
(cherry picked from commit 8b211b4)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…ILE`) (GH-97769) (#97871)

:c:type:`FILE` -> :c:expr:`FILE`
(cherry picked from commit 192d401)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…:c:expr:`PyTupleObject*`) (GH-97780) (#97863)

:c:type:`PyTupleObject*` -> :c:expr:`PyTupleObject*`
(cherry picked from commit 510baa4)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…:c:expr:`PyBytesObject*`) (GH-97782) (#97861)

:c:type:`PyBytesObject*` -> :c:expr:`PyBytesObject*`
(cherry picked from commit 9ebc508)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…> :c:expr:`PyUnicodeObject*`) (GH-97783) (#97859)

:c:type:`PyUnicodeObject*` -> :c:expr:`PyUnicodeObject*`
(cherry picked from commit 898834e)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
…expr:`Py_UNICODE*`) (GH-97784) (#97857)

:c:type:`Py_UNICODE*` -> :c:expr:`Py_UNICODE*`
(cherry picked from commit a081cae)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
pablogsal pushed a commit that referenced this issue Oct 22, 2022
:c:data:`0` -> ``0``
(cherry picked from commit 5e997cf)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes 3.12 bugs and security fixes docs Documentation in the Doc dir topic-C-API
Projects
Archived in project
Development

No branches or pull requests

6 participants