docstring

Replacing a SimpleString inside a libcst function definition? (dataclasses.FrozenInstanceError: cannot assign to field 'body')

Replacing a SimpleString inside a libcst function definition? (dataclasses.FrozenInstanceError: cannot assign to field 'body') Question: Context While trying to use the libcst module, I am experiencing some difficulties updating a documentation of a function. MWE To reproduce the error, the following minimal working example (MWE) is included: from libcst import ( # type: ignore[import] Expr, …

Total answers: 1

Doxygen for Python produces bad formatting since an update

Doxygen for Python produces bad formatting since an update Question: I’m using doxygen for a while to document my project. However in a new computer with a newer version of doxygen (1.9.1) it produces bad formatting for function docstrings. I attach an image that summarises very well the issue. The documentation right after the first …

Total answers: 1

sphinx-autoapi fails to combine class and __init__ docstrings (autoapi_python_class_content = 'both')

sphinx-autoapi fails to combine class and __init__ docstrings (autoapi_python_class_content = 'both') Question: sphinx-autoapi allows to combine the class docstrings and the __init__ docstrings using the autoapi_python_class_content = ‘both’ option. However, even with this option set (conf.py), it fails to properly combine the docstrings: The class SingleOutputEcospold2Importer class SingleOutputEcospold2Importer(LCIImporter): """ Class for importing single-output ecospold2 format …

Total answers: 1

how to dynamically change indentation in a multiline string?

how to dynamically change indentation in a multiline string? Question: I’m using docstrings to document my code with Sphinx. I recently started to use ruff to lint my code and It is by default applying D212 instead of D213. The only difference being that the first line of the docstring (short description) must start on …

Total answers: 2

Reference Python module docstring from within a class

Reference Python module docstring from within a class Question: Consider the following code: """Module documentation.""" import argparse class HandleArgs() """Class documentation""" def __call__() """Method documentation""" parser = argparse.ArgumentParser(description= __doc__) This code will try to use the docstring for the method, not the module. How do I access the module docstring from within a method within …

Total answers: 1

How to Correctly Display Pipe/Vertical Bar Character in Python Docstrings Using Sphinx

How to Correctly Display Pipe/Vertical Bar Character in Python Docstrings Using Sphinx Question: I’d like to put in a Python docstring something like: output_dir │ categories.yaml │ └───images │ filename1.png │ filename1.png │ … │ └───masks filename1.png filename2.png … But this is visualized by Sphinx as: output_dir │ categories.yaml │ └───images │ filename1.png │ filename1.png …

Total answers: 1

How do you style docstrings in python?

How do you style docstrings in python? Question: I want to style docstrings but I wasn’t able to find a clear document detailing how to go about it """ line 1 – I want this in bold line 2 – I want this in italics line 3 – I want the text color different /n …

Total answers: 1

Persistent cache during deployment with sphinx-autoapi?

Persistent cache during deployment with sphinx-autoapi? Question: I have been stuck with a problem for several days without solutions. I am trying to deploy local docs generated with Sphinx to Gitlab pages. Below is my .gitlab-ci.yml on the root directory of the repos, and I am using the latest Ubuntu image: stage: deploy script: – …

Total answers: 1

How do you specify return type on a callable parameter with reST docstring?

How do you specify return type on a callable parameter with reST docstring? Question: Here’s a working example with type hinting where I can annotate the parameter that it takes an int and a string and returns a boolean: from typing import Callable def func(another_func: Callable[[int, str], bool]): pass The relevant part is -> bool …

Total answers: 1

Can't generate Python docstring with autoDocstring extension in VS Code when multiline string in the function body

Can't generate Python docstring with autoDocstring extension in VS Code when multiline string in the function body Question: To generate documentation with Python Sphinx I have to use a specific docstring format. VS Code extension autoDocstring is capable to generate this specific format, but if the function contains multiline string then it doesn’t work. Example …

Total answers: 2