doxygen-> doxy2swig-> PDOC导致重复的类docstrings

发布于 2025-01-21 09:48:31 字数 880 浏览 2 评论 0原文

我有一个C ++标头文件(.H),该文件(通过SWIG)为我生成一个Python模块。我的目标是在生成的.py文件中包含来自.h文件的doxygen文档,但是由于我目前无法使用通过SWIG支持这一点的最新SWIG(V4+),所以我使用doxygen和doxy2swig来实现这一目标。

我的过程如下:

  • 在.h文件上运行doxygen以生成xml输出
  • 在xml输出上运行doxy2swig,以生成一个带有%docString insertion
  • 更新我的project my project my file
  • swig on。 生成的。
  • 包括在生成的.py文件上运行pdoc的

doxy2swig ,导致重复的描述。

我正在寻找一种做以下方法之一的方法:

  • 强制doxy2swig仅在类或_ init
  • 强制pdoc忽略类或__ init __ init __ init __

我已经尝试过的情况查看:

  • __ PDOC __ [class .__ Int __] = false。这是行不通的,即使这样做也意味着将我所有的课程添加到此范围内。
  • 手动修改了Doxy2swig生成的.i文件以将DOCSTRING附加到类。 init 而不是类。这是一种无效的格式。
  • 找不到任何可以帮助我的PDOC或doxy2swig参数 - 希望与我认为存在的类似的sphinx选项相似,这些选项将类文档排除在生成的文档中,或者排除__ INT __ INT __ INT __ INT __ INT __的内容。医生。

I have a C++ header file (.h) that (through swig) I generate a python module for. My goal is to include the Doxygen documentation from the .h file in the generated .py file, but since I am currently unable to use the latest swig (v4+) that supports this through swig, I am using Doxygen and doxy2swig to accomplish this.

My process is as follows:

  • run Doxygen on .h file to generate xml output
  • run doxy2swig on xml output to generate a .i file with %docstring insertion
  • update my project's .i file
  • run swig on .h file (with a .i file that includes the doxy2swig generated .i file)
  • run pdoc on generated .py file to generate interface documentation

I've found that doxy2swig inserts docstrings in both the class and __init__ docstrings, and pdoc concatenates these in the generated documentation, resulting in duplicate descriptions.

I am looking for a way to do one of the following:

  • force doxy2swig to only insert docstrings in class OR _init
  • force pdoc to ignore class or __init__

This I have tried/looked into:

  • __pdoc__[class.__init__] = False. This didn't work, and even if it did it would mean adding all of my classes to this dict.
  • manually modified the doxy2swig generated .i file to append docstring to class.init instead of class. This was an invalid format.
  • Couldn't find any pdoc or doxy2swig arguments that would help me with this - was hoping for something similar to the sphinx options that I believe exist for excluding class documentation from generated docs, or something to exclude the __init__ doctoring.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苹果你个爱泡泡 2025-01-28 09:48:31

您可以修改 pdoc的html html template 为了。以下是自定义module.html.jinja2的一些示例:

__ __ INT __ INT __

{% extends "default/module.html.jinja2" %}
{% macro docstring(var) %}
    {% if var.name != "__init__" %}
        {{ default_docstring(var) }}
    {% endif %}
{% endmacro %}

hide class-level docstrings:hide __ INT __ INT __ INT __ INT __ INT __

{% extends "default/module.html.jinja2" %}
{% macro docstring(var) %}
    {% if var.type != "class" %}
        {{ default_docstring(var) }}
    {% endif %}
{% endmacro %}

完全:完全:

{% extends "default/module.html.jinja2" %}
{% macro is_public(doc) %}
    {% if doc.name != "__init__" %}
        {{ default_is_public(doc) }}
    {% endif %}
{% endmacro %}

You can modify pdoc's HTML template to accomplish what you are looking for. Here are some examples for a custom module.html.jinja2:

Hide docstrings for __init__:

{% extends "default/module.html.jinja2" %}
{% macro docstring(var) %}
    {% if var.name != "__init__" %}
        {{ default_docstring(var) }}
    {% endif %}
{% endmacro %}

Hide class-level docstrings:

{% extends "default/module.html.jinja2" %}
{% macro docstring(var) %}
    {% if var.type != "class" %}
        {{ default_docstring(var) }}
    {% endif %}
{% endmacro %}

Hide __init__ entirely:

{% extends "default/module.html.jinja2" %}
{% macro is_public(doc) %}
    {% if doc.name != "__init__" %}
        {{ default_is_public(doc) }}
    {% endif %}
{% endmacro %}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文