Excluding in-code comments from displayed code snippets in Sphinx documentation

42 Views Asked by At

In our Python project, we extensively use in-code comments to tag team members or leave important messages for collaboration purposes, like so:

...
with var_model:
    # FIXME: #38 make these arguments specifiable in the parameters.json file 
    trace = pm.sample(2000, tune=1000, cores=2)

While this practice is crucial for our development workflow, it poses a challenge for generating clean and focused documentation with Sphinx. Specifically, when including the code snippets in the documentation, we want to present the code without these in-line comments (i.e., anything that starts with #) to ensure the documentation remains clear and concise for the end users.

Is there a functionality within Sphinx or a recommended technique that allows for automatically excluding these comments from code blocks when generating the documentation? The aim is to keep the source code as is for developers but provide a cleaner view in the documentation itself.

0

There are 0 best solutions below