Document Python code with Doxygen

When documenting Python code in Doxygen, I'll leave the memo as it fits.

For comments in docstring format in python, when you place the cursor on the function, the comment will be displayed by the editing support function of VScode.

■ docstring format comment example


def leftCosets(self, H: FiniteGroup) -> Set[Set[GroupElement]]:
	"""
	@brief Calculates left cosets of H in self.

	@details foo

	:param H: subGroup of self
	:return:

	@note bar
	"""

	cosets = {frozenset(copy.deepcopy(H.elements)),}
	remain = self.elements - H.elements

	while len(remain) > 0:
		#~ Omitted ~

	return cosets

It is convenient because you can check it in the comment without moving to the function definition position just by hovering the cursor over the function.

However, the docstring format doesn't look good when documented in Doxygen because "no special commands in doxygen are supported". --I have documented a Python project in Doxygen, but the parameters are not listed properly.

So we use a filter that converts the docstring format to the doxygen format.

■ Filter to convert docstring format to Doxygen format doxyfilter_python(GitHub)

This filter converts the docstring format to doxygen format and passes it to Doxygen.

■ Doxygen format comment example

	##
	#@brief Calculates left cosets of H in self.
	#@details foo
	#
	#@param H (FiniteGroup) subGroup of self
	#@return (Set[Set[GroupElement]])
	#
	#@note bar
	def leftCosets(self, H: FiniteGroup) -> Set[Set[GroupElement]]:
	cosets = {frozenset(copy.deepcopy(H.elements)),}
	remain = self.elements - H.elements

	while len(remain) > 0:
		#~ Omitted ~

	return cosets

python:doxyfilter_python.py


import io

#~ Omitted ~ perform_Add the following line at the beginning of the fh function
        sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')


#~ Omitted ~ Specify the encoding in the file open part of the main function.
        with open(file, 'r',encoding='utf-8') as fh:

■ Precautions such as Doxygen settings

Python looks more like Java than C or C ++, so set OPTMIZE_OUTPUT_JAVA to YES in the configuration file.

From "Comment blocks in Python"

-Be sure to leave one line between @brief and @details. Otherwise, the VS Code tooltip will display the items as a single line without line breaks. -Be sure to include a file comment. Otherwise the global method will not be documented.

From "Using Doxygen with Python3 with VS Code Editing Assistance"

--Expert tab-> Topics-> Input-> Specify doxyfilter_python.py with full path in INPUT_FILTER.

For the site I referred to ("Use Doxygen with Python3 while taking advantage of VS Code editing support")

Be sure to specify doxyfilter_python.py with the full path and explicitly state that it will run in python3 (otherwise it failed).

Although it is written, it seems that it is not necessary to specify python3 in an environment where only python3.x series is included.

Recommended Posts

Document Python code with Doxygen
Get country code with python
Python with VS Code (Windows 10)
Debug Python with VS Code
Install python with mac vs code
FizzBuzz with Python3
Scraping with Python
Statistics with python
Scraping with Python
Python with Go
Twilio with Python
Integrate with Python
Play with 2016-Python
python character code
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
[Automation] Read a Word document with Python
Python here document
Excel with Python
Microcomputer with Python
Cast with python
Build Python development environment with Visual Studio Code
Python (Windows 10) Virtual Environment / Package with VS Code
Debug with VS Code using boost python numpy
Automatically format Python code into PEP8-compliant code with Emacs
Use Python in Anaconda environment with VS Code
Convert the character code of the file with Python3
Static analysis of Python code with GitLab CI
[Blender x Python] Think of code with symbols
Make your Python environment "easy" with VS Code
Build a python execution environment with VS Code
Serial communication with Python
Zip, unzip with python
Django 1.11 started with Python3.6
Primality test with Python
Python with eclipse + PyDev.
Socket communication with Python
Data analysis with python 2
Scraping with Python (preparation)
Try scraping with Python.
Learning Python with ChemTHEATER 03
Sequential search with Python
"Object-oriented" learning with python
Run Python with VBA
Handling yaml with python
Solve AtCoder 167 with python
[Python] Use JSON with Python
Strengthen with code test ⑨
Learning Python with ChemTHEATER 05-1
Strengthen with code test ③
Learn Python with ChemTHEATER
Run prepDE.py with python3
1.1 Getting Started with Python
Collecting tweets with Python
Binarization with OpenCV / Python
3. 3. AI programming with Python
Python code acceleration approach