推荐学习书目
› 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 · Nov 3, 2023 · 2044 views
    This topic created in 1062 days ago, the information mentioned may be changed or developed.
    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 仓库的文档,但是生成的文档并没有包含这些内容。所以请教一下各位大佬如何处理这种情况。

    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4513 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 09:04 · PVG 17:04 · LAX 02:04 · JFK 05:04
    ♥ Do have faith in what you're doing.