1 个不稳定版本

0.1.0 2020年6月25日

#761 in 文本处理

GPL-3.0-only

62KB
1.5K SLoC

GodotDoc

GodotDoc 是 GdScript 的文档生成器。

它提取所有符号及其周围的注释,并生成一个 Markdown 文件,例如用于在 github 上显示。

考虑以下示例

# This comment is a description of the method foo
func foo(id):
	return id + 42

# We can exclude functions from showing up
# [Hide]
func _bar():
	return 1337

# Besides functions, one can declare classes, enums, variables, constants
class MyClass:
	# One can even comment on individual variables in a class or enum
	var baz
	var test # Even comments on the same line as the declaration are honored

# Enums list all values
enum MyEnum {
	FIRST = 0, # This is the first entry
	SECOND,
	GAP = 42, # Here we have a gap in the numbering
	LAST
}

# Export arguments are honored too
export(int, 1, 8) var my_export = 5

# As well as types
const MY_CONST: int = 42

# Setter and getter will be visible in the docs as well
var my_var setget foo, _bar

现在可以调用 godotdoc /path/to/source/directory -o /path/to/output/directory

这将得到以下结果

test.gd

  • MyClass

    Besides functions, one can declare classes, enums, variables, constants
    
    • 变量:

      • baz
      One can even comment on individual variables in a class or enum
      
      • test
      Even comments on the same line as the declaration are honored
      

枚举

  • MyEnum
    :

    • FIRST = 0
    This is the first entry
    
    • SECOND = 1
    • GAP = 42
    Here we have a gap in the numbering
    
    • LAST = 43

导出

  • my_export: (int, 1, 8) = 5

    Export arguments are honored too
    

常量

  • MY_CONST: int = 42

    As well as types
    

函数

  • foo(id)

    This comment is a description of the method foo
    

变量

  • my_var
    获取器: _bar
    设置器: foo

    Setter and getter will be visible in the docs as well
    

GodotDoc 会尝试从源目录中读取名为 godotdoc_config.json 的文件。此文件可以提供项目范围内生成文件的配置。这可以是一个示例配置

{
    "backend": "markdown",
    "excluded_files": [
        "./path/to/secret/directory",
	"./or/some/pattern/*.gd"
    ],
    "show_prefixed": true
}

这将设置文档生成的默认后端为 Markdown(目前唯一的后端),并排除 "path/to/secret/directory" 和 "or/some/pattern" 中所有的 .gd 文件被处理。选项 "show_prefixed" 控制,是否显示以 "_" 为前缀的成员。这可以通过 # [显示]# [隐藏] 在每个成员的基础上覆盖。

这些默认值可以通过命令行参数覆盖,例如使用 --backend=markdown 设置要使用的后端(不能通过参数设置 excluded_files)。

安装说明

此应用程序是用 Rust 编写的,因此您需要安装 Rust 工具链

要安装此应用程序

  1. 克隆此仓库: git clone https://github.com/Dragoncraft89/godotdoc.git
  2. 调用 cargo,Rust 包管理器来安装它 "cargo install --path godotdoc"

依赖项

~1.2–2.2MB
~41K SLoC