Skip to content

Issue #60 - Ensure docstrings adhere to PEP-8/Google Python Style Guide - #70

Merged
john-boyer-phd merged 14 commits into
masterfrom
Issue60-PolishDocstrings
Aug 26, 2026
Merged

Issue #60 - Ensure docstrings adhere to PEP-8/Google Python Style Guide #70
john-boyer-phd merged 14 commits into
masterfrom
Issue60-PolishDocstrings

Conversation

@wbkboyer

@wbkboyer wbkboyer commented Aug 19, 2026

Copy link
Copy Markdown
Member

Resolves #60

Type of change

Please check only relevant options:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) - Changed return value from int to None for Graph class method gp_ExtendWith_DrawPlanar()
  • This change requires a documentation update - see 1. Setup Instructions - Locally building the documentation

Changes

Added

  • doc/make.bat - autogenerated by sphinx-quickstart to build docs on Windows

Updated

  • requirements.txt - Added codespell (ran it locally to ensure no typos had been made) and cython-lint (ran it locally on all .pyx and .pxd files in the planarity.full subpackage to remediate as many long lines and trailing whitespace issues as was sensible: cython-lint --max-line-length 80 <filename>)
    • NOTE: I left the max line length as 80 rather than 79 because there's too many instances where it would just be too fussy to line-break. As well, contrary to PEP-8, it seems like the default line-length for cython-lint is 88 as per the PyPI page.
  • Extensive changes to formatting of all .pyx and .pxd files to better adhere to PEP-8 standards, as well as to conform to the Google Python Style Guide (in particular the formatting for docstrings).
  • planarity/full/graph.pyx - Changed API for Graph class method gp_ExtendWith_DrawPlanar() so that it no longer returns result so that it matches the other "extend with" methods.
  • Recompiled extensions during testing using pip install . to refresh .c files using Cython 3.2.9

Removed

  • Leftover contents of doc directory from previous documentation generation with sphinx circa 2011

Testing

  1. Ran pip install . in a Python 3.14.6 virtual environment

  2. Ran pytest and all tests passed (no changes to classic package so this makes sense, but still shows the whole package is installed and runs).

  3. Ran through examples/full/ test scripts.

  4. Ran EAPS-T test_all_graphs.py and test_table_generation_with_numInvalidOKs.py to regenerate test tables for N=8` and compared to existing tables on EAPS (which uses old subprocess-based approach), e.g.:

    icdiff -W -s ../output/tables/8/n8.mALL.4.out.txt ~/git/edge-addition-planarity-suite-fork/TestSupport/tables/8/n8.mALL.4.out.txt
    
  5. From the doc directory, ran make html and make latexpdf to automatically generate the documentation from the docstrings. Using the napoleon extension means that we should be validating the docstring formatting (although I tried to delete a period from the end of one of the components and it didn't squawk at me :( )

Investigation into how to ensure docstrings adhere to Google Python style

TODO: use a Google docstring parser tool to ensure manual formatting has been done correctly. For example:

…er adhere to PEP-8 standards, as well as to conform to the Google Python Style Guide (in particular the formatting for docstrings). Additionally, used `cython-lint` tool on `graph.pyx` to help find these warts:

```
cython-lint --max-line-length 80 planarity/full/graph.pyx
```

Note: I left the max line length as 80 rather than 79 because there's too many instances where it would just be too fussy to line-break and it's not like the single column matters that much.

Also recompiled extensions  to produce .c files using Cython 3.2.9
…recompiled cythonized extension `.c` files with Cython 3.2.9. Added codespell to `requirements.txt` because I ran it locally to ensure no typos made.

Used `cython-lint --max-line-length 80 <filename>` and went over each file to remediate as many long lines and trailing whitespace issues as was sensible.

After running `pip install .` in a Python 3.14.6 virtual environment, ran `pytest` and all tests passed (no changes to `classic` package so this makes sense, but still shows the whole package is installed and runs). Ran through `examples/full/` test scripts. Ran EAPS-T `test_all_graphs.py` and `test_table_generation_with_numInvalidOKs.py` to regenerate test tables for N=8` and compared to existing tables on EAPS (which uses old subprocess-based approach), e.g.:

```
icdiff -W -s ../output/tables/8/n8.mALL.4.out.txt ~/git/edge-addition-planarity-suite-fork/TestSupport/tables/8/n8.mALL.4.out.txt
```
wbkboyer and others added 10 commits August 18, 2026 18:32
To generate these docs, when at the root of the planarity project, run:
      sphinx-apidoc -o doc/source planarity
Then:
      sphinx-build -M html doc/source doc/build
OR from the doc directory, run
      make html

If you wish to generate a .pdf, replace "html" with "latexpdf".

Need to figure out how to publish these docs to GitHub Pages. Note that I opted to not include the compiled files, since these should be automatically regenerated from the actual docstrings.
…todoc defaults are not behaving as expected. However, we now have a very simple way to build the docs without having to manually run sphinx-apidoc before sphinx-build:

   To generate these docs, when at the root of the planarity project, run:
      sphinx-build -M html doc/source doc/build
   OR from the doc directory, run
      make html
… locally by:

1. Cloning the repo
2. Setting up a fresh virtual environment by running `python3.14 -m venv .venv` and then activate it
3. Installing requirements.txt by `pip install -r requirements.txt`
4. `cd doc && make html`

 Also, for now, ignore the build artifacts using .gitignore.
Can't figure out how to get rid of module-level `__reduce_cython__` and `__setstate_cython__` holders... They're being skipped for the Classes (did some tests by adding debug statements to `conf.py` to try to see what was going on)

The reason why __cinit__ and __dealloc__ docstrings aren't being promoted to the autogenerated docs is, according to https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html#docstrings, as follows:

"You can place a docstring in the source to serve as a comment, but it won’t show up in the corresponding __doc__ attribute at run time. (This seems to be is a Python limitation – there’s nowhere in the PyTypeObject data structure to put such docstrings.)"
…onfiguration.

I still can't exclude the module-level `__reduce_cython__()` nor `__setstate_cython__()` functions from the final generated html pages. It seems like autodoc was already correctly excluding those methods on the *classes*, but for some reason some other part of the pipeline is including these members.

Increased the `toctree` `maxdepth` to 7 so that we can navigate to the class documentation from the `index.rst`.
…irtual environment site-packages rather than having to separately build_ext.
john-boyer-phd
john-boyer-phd previously approved these changes Aug 26, 2026

@john-boyer-phd john-boyer-phd left a comment

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.

This is looking great! Clearly, in hindsight, it wasn't going to work to just make a single first docstring sentence for various functions when the real goal was to end up with an API doc. Way to go!

…their docstrings do not get promoted to the final documentation tree.

@john-boyer-phd john-boyer-phd left a comment

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.

Looks great. I really like that depth 8 setting because I like the clickable table of contents up front, not just as an index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remediate long doc string descriptions

2 participants