Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb2d0a02

Browse files
committed
minimal working breathe/sphinx/doxygen/pybind11 example
1 parentf94973b commitb2d0a02

File tree

12 files changed

+362
-9
lines changed

12 files changed

+362
-9
lines changed

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Build directory
22
build
3+
docs/_build
4+
5+
# Python
6+
*.egg-info
7+
8+
# VS Code
9+
.vscode
310

411
# Prerequisites
512
*.d

‎docs/Doxyfile‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
PROJECT_NAME = python_cpp_example
2+
INPUT = ../python_cpp_example/
3+
4+
GENERATE_HTML = NO
5+
GENERATE_LATEX = NO
6+
GENERATE_XML = YES
7+
XML_OUTPUT = _build/doxygenxml
8+
XML_PROGRAMLISTING = YES
9+
10+
MACRO_EXPANSION = YES
11+
EXPAND_ONLY_PREDEF = YES
12+
EXPAND_AS_DEFINED = PYBIND11_RUNTIME_EXCEPTION
13+
14+
ALIASES = "rst=\verbatim embed:rst"
15+
ALIASES += "endrst=\endverbatim"
16+
17+
QUIET = YES
18+
WARNINGS = YES
19+
WARN_IF_UNDOCUMENTED = NO

‎docs/Makefile‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = python3 -msphinx
7+
SPHINXPROJ = Python-CPPExample
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -Mhelp"$(SOURCEDIR)""$(BUILDDIR)"$(SPHINXOPTS)$(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M$@"$(SOURCEDIR)""$(BUILDDIR)"$(SPHINXOPTS)$(O)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
python\_cpp\_example\.add
2+
=========================
3+
4+
..currentmodule::python_cpp_example
5+
6+
..autofunction::add
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
python\_cpp\_example\.subtract
2+
==============================
3+
4+
..currentmodule::python_cpp_example
5+
6+
..autofunction::subtract

‎docs/conf.py‎

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Python-CPP Example documentation build configuration file, created by
5+
# sphinx-quickstart on Tue Jun 6 15:44:28 2017.
6+
#
7+
# This file is execfile()d with the current directory set to its
8+
# containing dir.
9+
#
10+
# Note that not all possible configuration values are present in this
11+
# autogenerated file.
12+
#
13+
# All configuration values have a default; values that are commented out
14+
# serve to show the default.
15+
16+
# If extensions (or modules to document with autodoc) are in another directory,
17+
# add these directories to sys.path here. If the directory is relative to the
18+
# documentation root, use os.path.abspath to make it absolute, like shown here.
19+
#
20+
importos
21+
importsys
22+
# sys.path.insert(0, os.path.abspath('.'))
23+
24+
25+
# -- General configuration ------------------------------------------------
26+
27+
# If your documentation needs a minimal Sphinx version, state it here.
28+
#
29+
# needs_sphinx = '1.0'
30+
31+
# Add any Sphinx extension module names here, as strings. They can be
32+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
33+
# ones.
34+
extensions= [
35+
'sphinx.ext.autodoc',
36+
'sphinx.ext.intersphinx',
37+
'sphinx.ext.autosummary',
38+
'sphinx.ext.napoleon',
39+
'breathe'
40+
]
41+
42+
autosummary_generate=True
43+
44+
breathe_projects= {"python_cpp_example":"_build/doxygenxml/" }
45+
breathe_default_project="python_cpp_example"
46+
breathe_domain_by_extension= {'hpp':'cpp'}
47+
48+
# Add any paths that contain templates here, relative to this directory.
49+
templates_path= ['_templates']
50+
51+
# The suffix(es) of source filenames.
52+
# You can specify multiple suffix as a list of string:
53+
#
54+
# source_suffix = ['.rst', '.md']
55+
source_suffix='.rst'
56+
57+
# The master toctree document.
58+
master_doc='index'
59+
60+
# General information about the project.
61+
project='Python-CPP Example'
62+
copyright='2017, Benjamin Jack'
63+
author='Benjamin Jack'
64+
65+
# The version info for the project you're documenting, acts as replacement for
66+
# |version| and |release|, also used in various other places throughout the
67+
# built documents.
68+
#
69+
# The short X.Y version.
70+
version='0.1'
71+
# The full version, including alpha/beta/rc tags.
72+
release='0.1'
73+
74+
# The language for content autogenerated by Sphinx. Refer to documentation
75+
# for a list of supported languages.
76+
#
77+
# This is also used if you do content translation via gettext catalogs.
78+
# Usually you set "language" from the command line for these cases.
79+
language=None
80+
81+
# List of patterns, relative to source directory, that match files and
82+
# directories to ignore when looking for source files.
83+
# This patterns also effect to html_static_path and html_extra_path
84+
exclude_patterns= ['_build','Thumbs.db','.DS_Store']
85+
86+
# The name of the Pygments (syntax highlighting) style to use.
87+
pygments_style='sphinx'
88+
89+
# If true, `todo` and `todoList` produce output, else they produce nothing.
90+
todo_include_todos=False
91+
92+
93+
# -- Options for HTML output ----------------------------------------------
94+
95+
# The theme to use for HTML and HTML Help pages. See the documentation for
96+
# a list of builtin themes.
97+
#
98+
html_theme='alabaster'
99+
100+
# Theme options are theme-specific and customize the look and feel of a theme
101+
# further. For a list of options available for each theme, see the
102+
# documentation.
103+
#
104+
# html_theme_options = {}
105+
106+
# Add any paths that contain custom static files (such as style sheets) here,
107+
# relative to this directory. They are copied after the builtin static files,
108+
# so a file named "default.css" will overwrite the builtin "default.css".
109+
html_static_path= ['_static']
110+
111+
112+
# -- Options for HTMLHelp output ------------------------------------------
113+
114+
# Output file base name for HTML help builder.
115+
htmlhelp_basename='Python-CPPExampledoc'
116+
117+
118+
# -- Options for LaTeX output ---------------------------------------------
119+
120+
latex_elements= {
121+
# The paper size ('letterpaper' or 'a4paper').
122+
#
123+
# 'papersize': 'letterpaper',
124+
125+
# The font size ('10pt', '11pt' or '12pt').
126+
#
127+
# 'pointsize': '10pt',
128+
129+
# Additional stuff for the LaTeX preamble.
130+
#
131+
# 'preamble': '',
132+
133+
# Latex figure (float) alignment
134+
#
135+
# 'figure_align': 'htbp',
136+
}
137+
138+
# Grouping the document tree into LaTeX files. List of tuples
139+
# (source start file, target name, title,
140+
# author, documentclass [howto, manual, or own class]).
141+
latex_documents= [
142+
(master_doc,'Python-CPPExample.tex','Python-CPP Example Documentation',
143+
'Benjamin Jack','manual'),
144+
]
145+
146+
147+
# -- Options for manual page output ---------------------------------------
148+
149+
# One entry per manual page. List of tuples
150+
# (source start file, name, description, authors, manual section).
151+
man_pages= [
152+
(master_doc,'python-cppexample','Python-CPP Example Documentation',
153+
[author],1)
154+
]
155+
156+
157+
# -- Options for Texinfo output -------------------------------------------
158+
159+
# Grouping the document tree into Texinfo files. List of tuples
160+
# (source start file, target name, title, author,
161+
# dir menu entry, description, category)
162+
texinfo_documents= [
163+
(master_doc,'Python-CPPExample','Python-CPP Example Documentation',
164+
author,'Python-CPPExample','One line description of project.',
165+
'Miscellaneous'),
166+
]
167+
168+
169+

‎docs/index.rst‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Welcome to Python-CPP Example's documentation!
2+
==============================================
3+
4+
Contents:
5+
6+
..toctree::
7+
:maxdepth:2
8+
9+
python_cpp_example
10+
11+
..doxygenfunction::add
12+
13+
Indices and tables
14+
==================
15+
16+
*:ref:`genindex`
17+
*:ref:`modindex`
18+
*:ref:`search`

‎docs/make.bat‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@ECHOOFF
2+
3+
pushd%~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if"%SPHINXBUILD%"=="" (
8+
setSPHINXBUILD=python -msphinx
9+
)
10+
setSOURCEDIR=.
11+
setBUILDDIR=_build
12+
setSPHINXPROJ=Python-CPPExample
13+
14+
if"%1"==""goto help
15+
16+
%SPHINXBUILD%>NUL2>NUL
17+
iferrorlevel9009 (
18+
echo.
19+
echo.The Sphinx module was not found. Make sure you have Sphinx installed,
20+
echo.then set the SPHINXBUILD environment variable to point to the full
21+
echo.path of the 'sphinx-build' executable. Alternatively you may add the
22+
echo.Sphinx directory to PATH.
23+
echo.
24+
echo.If you don't have Sphinx installed, grab it from
25+
echo.http://sphinx-doc.org/
26+
exit /b1
27+
)
28+
29+
%SPHINXBUILD% -M%1%SOURCEDIR%%BUILDDIR%%SPHINXOPTS%
30+
goto end
31+
32+
:help
33+
%SPHINXBUILD% -M help%SOURCEDIR%%BUILDDIR%%SPHINXOPTS%
34+
35+
:end
36+
popd

‎docs/python_cpp_example.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
..automodule::python_cpp_example

‎python_cpp_example/bindings.cpp‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@
33

44
namespacepy= pybind11;
55

6-
PYBIND11_PLUGIN(cmake_example)
6+
PYBIND11_PLUGIN(python_cpp_example)
77
{
8-
py::modulem("cmake_example",R"pbdoc(
8+
py::modulem("python_cpp_example",R"doc(
99
Pybind11 example plugin
1010
-----------------------
11-
.. currentmodule::cmake_example
11+
.. currentmodule::python_cpp_example
1212
.. autosummary::
1313
:toctree: _generate
14+
1415
add
1516
subtract
16-
)pbdoc");
17+
)doc");
1718

18-
m.def("add", &add,R"pbdoc(
19+
m.def("add", &add,R"doc(
1920
Add two numbers
2021
Some other explanation about the add function.
21-
)pbdoc");
22+
)doc");
2223

23-
m.def("subtract", &subtract,R"pbdoc(
24+
m.def("subtract", &subtract,R"doc(
2425
Subtract two numbers
2526
Some other explanation about the subtract function.
26-
)pbdoc");
27+
)doc");
2728

2829
#ifdef VERSION_INFO
2930
m.attr("__version__") =py::str(VERSION_INFO);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp