gpt4 book ai didi

c - Doxygen:在源代码浏览器中隐藏部分源代码

转载 作者:行者123 更新时间:2023-12-05 01:35:26 25 4
gpt4 key购买 nike

  • 通常我希望 Doxygen 允许查看文档文件的源代码。但我想要一个 部分源代码被隐藏 .
    我知道如何强制 Doxygen 不记录某些代码段(例如使用/cond/endcond),但在单击“转到此文件的源代码”时它仍然出现。

    我真正想要的是:如果某些内容没有以 Doxygen 风格进行注释,它就不会出现在任何地方,不会出现在文档中,也不会出现在“转到此文件的源代码”中。
    对于函数以及 #-defines 或其他任何内容,情况都是如此。
  • 我使用@hideinitializer 来隐藏#-defines 的初始化程序。这在文档中运行良好。但同样,初始化程序仍然显示在源代码中。

  • 有人有什么建议吗?

    最佳答案

    您可以通过使用 INPUT_FILTER 指定过滤器脚本/程序来预处理源文件。选项。然后,通过设置 FILTER_SOURCE_FILE = YES ,过滤后的源代码将在源浏览器中使用,而不是原始源。

    从文档:

    The INPUT_FILTER tag can be used to specify a program that doxygen should invoke to filter for each input file. Doxygen will invoke the filter program by executing (via popen()) the command:

    <filter> <input-file>

    where is the value of the INPUT_FILTER tag, and is the name of an input file. Doxygen will then use the output that the filter program writes to standard output.





    If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using INPUT_FILTER ) will also be used to filter the input files that are used for producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).



    作为一个粗略的例子,使用以下源代码(在与 Doxyfile 相同的位置保存为 filter.py,并使其可执行):
    #!/usr/bin/env python
    import fileinput, re

    # output all lines that does not start with // (but allow //!)
    for line in fileinput.input():
    if not re.match(r'\s*//(?![!])', line):
    print line,

    在 Doxyfile 中,设置:
    INPUT_FILTER = ./filter.py
    FILTER_SOURCE_FILE = YES

    输出源浏览器现在将只显示不以 // 开头的行.

    自然地,创建一个过滤器脚本来丢弃所有 C 风格的注释,除了那些与 doxygen 相关的注释将比上面显示的要复杂得多。

    关于c - Doxygen:在源代码浏览器中隐藏部分源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14360803/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com