【问题标题】:How to render Doxygen xml output into markdown instead of reST (using breathe or MyST-Parser)如何将 Doxygen xml 输出呈现为 markdown 而不是 reST(使用 Breath 或 MyST-Parser)
【发布时间】:2022-01-14 11:14:57
【问题描述】:

我正在使用Sphinx 准备项目文档,在哪里获取Doxygen XML output 我使用了breathe。我在.rst 文件中使用了呼吸指令。

sample.cpp

namespace X{
class A{
   public:
       int x;
};
}

在我刚刚添加的rst 文件中

.. doxygenclass:: X::A
   :members:
   :protected-members:
   :private-members:

构建项目后,我可以看到class A 的详细文档。出于某种原因,我打算使用markdown 文件而不是.rst

我浏览了几篇帖子,但找不到任何富有成效的答案。我得到的最好的一个this StackOverflow answer

  • 我已经安装了myst parser
  • 通过添加extensions = ["myst_parser",] 修改conf.py

编写.md文件如下:

# sample_md
```{doxygenclass:: X::A}
:members:
:protected-members:
:private-members:
```

但在错误消息为时失败

WARNING: unknown directive or role name: doxygenclass::A
/net/users/Linux_Home/user_name/project_name/doc/md_files/sample_mark.md:5: WARNING: Unknown directive type "doxygenclass::A".

也试过了

# sample_md
```{doxygenclass}
A
:members:
:protected-members:
:private-members:
```

同样失败和错误信息

Exception occurred:
  File "/net/users/Linux_Home/user_name/.local/lib/python3.8/site-packages/myst_parser/docutils_renderer.py", line 973, in run_directive
    if issubclass(directive_class, Include):
TypeError: issubclass() arg 1 must be a class
The full traceback has been saved in /tmp/sphinx-err-guubfd6h.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
make[2]: *** [doc/CMakeFiles/Sphinx.dir/build.make:63: doc/sphinx/index.html] Error 2
make[1]: *** [CMakeFiles/Makefile2:215: doc/CMakeFiles/Sphinx.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

现阶段不知道该做什么。

我在.md 文件中使用了以下片段

```{cpp:class} X::A
```

它显示了呈现的类,但只有带有可点击链接的名称,其中不存在 Doxygen XML 文档。我需要这些信息。

我的一些纪念活动是:

  • myST仅用于在markdown文件中收集Sphinx directive
  • breathe 是一个获取Doxygen XML output 并使用SphinxreST 样式写入的工具

现在我想知道,是否可以在.md 文件中添加breathe Doxygen directive?如果是,我在哪里使语法错误?

【问题讨论】:

  • 当您说“但失败”时,错误是什么?
  • 我已经添加了相应的错误信息

标签: c++ markdown python-sphinx doxygen myst


【解决方案1】:

得到答案here

现在markdown文件如下

```{eval-rst}
.. doxygenclass:: X::A

【讨论】:

    【解决方案2】:

    你能试试这个吗?

    ```{doxygenclass} X::A
    :members:
    :protected-members:
    :private-members:
    ```
    

    如果失败,报告错误?

    【讨论】:

    • 试过但失败了。 Exception occurred: File "/net/users/Linux_Home/user_name/.local/lib/python3.8/site-packages/myst_parser/docutils_renderer.py", line 973, in run_directive if issubclass(directive_class, Include): TypeError: issubclass() arg 1 must be a class The full traceback has been saved in /tmp/sphinx-err-rrzs5cm5.log, if you want to report the issue to the developers. Please also report this if it was a user error, so that a better error message can be provided next time. A bug report can be filed in the tracker at &lt;https://github.com/sphinx-doc/sphinx/issues&gt;. Thanks!
    • 有什么想法我会问这个问题(breathemySTSphinx)吗?
    • 在 MyST 中尝试!希望他们能迅速回答
    猜你喜欢
    • 1970-01-01
    • 2022-01-06
    • 2022-11-26
    • 2018-02-11
    • 1970-01-01
    • 2014-11-30
    • 2020-06-15
    • 2016-11-30
    • 2020-11-23
    相关资源
    最近更新 更多