sphinx-doc / sphinx-doc/sphinx

Print fields in declared order for classes that extend ctypes.Structure

Open
#9,865 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:enhancement
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem? Please describe.
Classes that extend ctypes.Structure typically represent native C structs, in which field order and types matter. Sphinx should consider preserving this order and type declaration in the generated documentation.

Describe the solution you'd like
Generated documentation preserves field order and type.

Describe alternatives you've considered
Only preserve field order.
Only preserve field type.

Additional context
Example source:

from ctypes import Structure, c_int

class test_struct(Structure):

    _fields_ = [ ('foo', c_int),
                 ('bar', c_int) ]

Currently, Sphinx (4.3.0) produces html like:

class sphinx_struct.test_struct
Bases: _ctypes.Structure

bar
Structure/Union member

foo
Structure/Union member

but foo should appear before bar and the type (c_int) should be presented.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided ctypes.Structure example using Sphinx 4.3.0 and inspect the generated HTML; the issue names no repository files or tests to start from. Done means the generated documentation preserves the fields declaration order and presents the declared c_int type.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.