forked from numpy/numpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request numpy#18884 from seiko2plus/breathe_doxygen
DOC: Add support for documenting C/C++ via Doxygen & Breathe
- Loading branch information
Showing
15 changed files
with
719 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
import subprocess | ||
import os | ||
import sys | ||
from string import Template | ||
|
||
def main(): | ||
doxy_gen(os.path.abspath(os.path.join('..'))) | ||
|
||
def doxy_gen(root_path): | ||
""" | ||
Generate Doxygen configration file. | ||
""" | ||
confs = doxy_config(root_path) | ||
build_path = os.path.join(root_path, "doc", "build", "doxygen") | ||
gen_path = os.path.join(build_path, "Doxyfile") | ||
if not os.path.exists(build_path): | ||
os.makedirs(build_path) | ||
with open(gen_path, 'w') as fd: | ||
fd.write("#Please Don't Edit! This config file was autogenerated by ") | ||
fd.write(f"doxy_gen({root_path}) in doc/preprocess.py.\n") | ||
for c in confs: | ||
fd.write(c) | ||
|
||
class DoxyTpl(Template): | ||
delimiter = '@' | ||
|
||
def doxy_config(root_path): | ||
""" | ||
Fetch all Doxygen sub-config files and gather it with the main config file. | ||
""" | ||
confs = [] | ||
dsrc_path = os.path.join(root_path, "doc", "source") | ||
sub = dict(ROOT_DIR=root_path) | ||
with open(os.path.join(dsrc_path, "doxyfile"), "r") as fd: | ||
conf = DoxyTpl(fd.read()) | ||
confs.append(conf.substitute(CUR_DIR=dsrc_path, **sub)) | ||
|
||
for dpath, _, files in os.walk(root_path): | ||
if ".doxyfile" not in files: | ||
continue | ||
conf_path = os.path.join(dpath, ".doxyfile") | ||
with open(conf_path, "r") as fd: | ||
conf = DoxyTpl(fd.read()) | ||
confs.append(conf.substitute(CUR_DIR=dpath, **sub)) | ||
return confs | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Generate C/C++ API reference documentation from comments blocks is now possible | ||
------------------------------------------------------------------------------- | ||
This feature depends on Doxygen_ in the generation process and on Breathe_ | ||
to integrate it with Sphinx. | ||
|
||
.. _`Doxygen`: https://www.doxygen.nl/index.html | ||
.. _`Breathe`: https://breathe.readthedocs.io/en/latest/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INPUT += @CUR_DIR | ||
INCLUDE_PATH += @CUR_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Template to represent limbo numbers. | ||
* | ||
* Specializations for integer types that are part of nowhere. | ||
* It doesn't support with any real types. | ||
* | ||
* @param Tp Type of the integer. Required to be an integer type. | ||
* @param N Number of elements. | ||
*/ | ||
template<typename Tp, std::size_t N> | ||
class DoxyLimbo { | ||
public: | ||
/// Default constructor. Initialize nothing. | ||
DoxyLimbo(); | ||
/// Set Default behavior for copy the limbo. | ||
DoxyLimbo(const DoxyLimbo<Tp, N> &l); | ||
/// Returns the raw data for the limbo. | ||
const Tp *data(); | ||
protected: | ||
Tp p_data[N]; ///< Example for inline comment. | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* This a simple brief. | ||
* | ||
* And the details goes here. | ||
* Multi lines are welcome. | ||
* | ||
* @param num leave a comment for parameter num. | ||
* @param str leave a comment for the second parameter. | ||
* @return leave a comment for the returned value. | ||
*/ | ||
int doxy_javadoc_example(int num, const char *str); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* A comment block contains reST markup. | ||
* @rst | ||
* .. note:: | ||
* | ||
* Thanks to Breathe_, we were able to bring it to Doxygen_ | ||
* | ||
* Some code example:: | ||
* | ||
* int example(int x) { | ||
* return x * 2; | ||
* } | ||
* @endrst | ||
*/ | ||
void doxy_reST_example(void); |
Oops, something went wrong.