erikaheidi/yamldocs

此包已被弃用,不再维护。作者建议使用yamldocs/yamldocs包。

YAML 参考构建器 / Markdown 文档生成器

1.0.4 2023-07-13 17:09 UTC

README

PHP Composer GitHub release (latest SemVer) GitHub Packagist Dependency Version Packagist Dependency Version

Yamldocs 是一个基于 YAML 文件的 Markdown 文档生成器,使用 PHP 和 Minicli 编写。它可以作为一个独立的应用程序使用,也可以作为 Composer 的 bin 命令包含在现有项目中。它可用于创建可通过模板和通用构建器接口自定义的自动化参考文档。

有关安装和使用说明,请访问文档网站

示例

示例 YAML

此 YAML 展示了定义文档的结构和生成的 Markdown 的方式

Section1: #structure is based on the actual yaml
  Item1: value0
  Item2: value1
  Item3:
    - value12
    - value13
  Item4: value2

Section2:
  Item1:
    - value12
    - value13
  Item2: value1
  Item3: value3
  Item4: value2

# The document is described in the _meta node, but there are no required fields. Markdown will be generated anyways,
# based on the structure of the YAML document.
_meta:
  # Each node has a description (info) and an array of items that will be presented as a table.
  Section1:
    info: Information about Section 1
    items:
      Item1: The first row
      Item2: The second row

  Section2:
    info: Information about Section 2
    items:
      Item3: The third row
      Item4: The fourth row
    # Setting up a custom example
    example: |
      Section2:
        Item1:
          - value01
          - value02

构建单个文档

./bin/yamldocs build markdown file=example.yaml output=example.md

生成的 Markdown 内容

    ## example.yaml
    example.yaml YAML reference
    
    
    ## Section1
    Information about Section 1
    
    ### Reference
    
    | Directive | Expects                 |
    |-----------|-------------------------|
    | Item1     | (String) The first row  |
    | Item2     | (String) The second row |
    | Item3     | (Array)                 |
    | Item4     | (String)                |
    
    
    ### Example
    
    ```yaml
    Section1:
      Item1: value0
      Item2: value1
      Item3:
        - value12
        - value13
      Item4: value2
    
    ```
    
    ## Section2
    Information about Section 2
    
    ### Reference
    
    | Directive | Expects                 |
    |-----------|-------------------------|
    | Item1     | (Array)                 |
    | Item2     | (String)                |
    | Item3     | (String) The third row  |
    | Item4     | (String) The fourth row |
    
    
    ### Example
    
    ```yaml
    Section2:
      Item1:
        - value01
        - value02
    ```

构建多个文档

使用 build docs 命令构建目录中所有 YAML 文件的 Markdown 文档。添加 --recursively 以构建子目录。

./bin/yamldocs build docs source=var/yaml output=var/output --recursive

有关更多信息和使用说明,请查看完整文档