Closed hgscott closed 11 months ago
To build everything inside of the docs folder, I had to run sphinx-build -b html docs/source docs/build
I have almost everything working to generate the docs from the doc strings, but I am getting these two errors:
/Users/helenscott/Documents/PhD/Segre-lab/cometspy/cometspy/layout.py:docstring of cometspy.layout.layout.add_external_reaction:16: WARNING: Inline strong start-string without end-string.
/Users/helenscott/Documents/PhD/Segre-lab/cometspy/cometspy/layout.py:docstring of cometspy.layout.layout.set_region_map:6: ERROR: Unexpected indentation.
I asked ChatGPT what these error messages mean, and I got this response:
The error messages you're encountering while building your Sphinx documentation relate to issues with the formatting of your docstrings in the Python module cometspy.layout.layout. Let's break down each error message:
WARNING: Inline strong start-string without end-string: This warning typically indicates that there's a formatting issue within your docstring, specifically around the use of inline markup. An "inline strong start-string" refers to a bold or strong text element, which is typically marked using double asterisks (**). The warning suggests that there is an unbalanced use of these markers, possibly missing an end-marker.
Check your docstrings for instances where you might have used double asterisks for bold text, and make sure they are properly balanced with opening and closing markers. For example, bold text.
ERROR: Unexpected indentation: This error message suggests that there is a problem with the indentation in your docstring. It's likely that there is an indentation inconsistency in the line mentioned in the error.
Make sure that the indentation within your docstrings follows the consistent indentation level of your code. Ensure that you're not mixing spaces and tabs for indentation, as that can sometimes cause unexpected behavior.
To resolve these issues:
For the warning about inline strong start-strings, review your docstrings and ensure that any inline markup (bold, italics, etc.) is properly balanced with opening and closing markers.
For the error about unexpected indentation, go to the line specified in the error message and check for indentation inconsistencies. Make sure the indentation in your docstrings matches the surrounding code.
Remember that proper reStructuredText (reST) formatting is crucial for Sphinx to correctly parse and render your documentation. Double-check your docstrings for any formatting issues and correct them accordingly.
There was indeed an unbalanced **
in line 240:
So I removed that.
And I think the indentation error was because of the indented numbered list on lines 193 and 194:
So I made the numbers flush with the text above it.
And that gave me no errors, when I built the HTML files!
Okay! Documentation is being generated and pushed to the website correctly!
Next, I want to make the index page more helpful/welcoming. Where do I write that so that it is not overwritten in the rst files everytime I build?
Playing around locally, it looks like the index.rst
file doesn't get generated from anything, so I can just edit that file and it will stay that way until I change it again.
The set-up is all done, but it would be nice to have a template/set of best practices for writing the docstrings to get the best documentation.
Hosting documentation for a Python package on GitHub can be done using various methods, but one of the most popular and effective ways is by using GitHub Pages along with a documentation generator like Sphinx. Here's a step-by-step guide on how to achieve this:
As you make changes to your package or its documentation, remember to update the documentation source and regenerate the HTML files. By using Sphinx and GitHub Pages, you can create and host comprehensive and user-friendly documentation for your Python package. Additionally, there are alternative documentation generators like MkDocs and Read the Docs that you might consider if they better match your needs.