V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
KADGang
V2EX  ›  Python

使用 Pybind11 来封装 Python 模块,如何用 Sphinx 为其生成 API 文档?

  •  
  •   KADGang · 176 天前 · 660 次点击
    这是一个创建于 176 天前的主题,其中的信息可能已经有所发展或是发生改变。
    PYBIND11_MODULE(python_example, m) {
        m.doc() = R"pbdoc(
            Pybind11 example plugin
            -----------------------
    
            .. currentmodule:: python_example
    
            .. autosummary::
               :toctree: _generate
    
               add
               subtract
        )pbdoc";
    
        m.def("add", &add, R"pbdoc(
            Add two numbers
    
            Some other explanation about the add function.
        )pbdoc");
    
        m.def("subtract", [](int i, int j) { return i - j; }, R"pbdoc(
            Subtract two numbers
    
            Some other explanation about the subtract function.
        )pbdoc");
    

    比如说我有这么一段代码,如何用 Sphinx 为python_example模块和它下面的函数生成 api 文档?我尝试过直接 make https://github.com/pybind/python_example 仓库的文档,但是生成的文档并没有包含这些内容。所以请教一下各位大佬如何处理这种情况。

    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3677 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 04:23 · PVG 12:23 · LAX 21:23 · JFK 00:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.