You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Related to #14
Add support for arbitrary levels of nesting in `yamldoc`.
* **Documentation Updates**
- Update `docs/hier_tutorial.md` to reflect support for arbitrary levels of nesting.
- Update `README.md` to remove the note about the two-level nesting limitation.
* **Code Changes**
- Modify `yamldoc/parser.py` to handle arbitrary levels of nesting.
- Update `yamldoc/parser.py` to add type metadata for deeper nested entries.
* **Test Updates**
- Add new test cases in `test/test_examples.py` for deeper nesting.
- Add new test cases in `test/test_exclude.py` for deeper nesting exclusion.
- Update `test/yaml/two_level.yaml` and `test/schema/two_level.schema` to include examples of deeper nesting.
---
For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/Chris1221/yamldoc/issues/14?shareId=XXXX-XXXX-XXXX-XXXX).
- Nested arrays past two levels of nesting. `yamldoc` will not parse nested arrays past two levels of nesting. [Issue #14](https://github.com/Chris1221/yamldoc/issues/14) tracks this request.
34
31
- Multi-line strings (unquoted or quoted scalars) indicated by `|` or `>` are not supported.
35
32
- Lists of dictionaries are not supported.
36
33
- Multiple documents in a single file are supported, but no special handling is done to separate them. It is assumed that each document is a separate configuration file.
`yamldoc` now supports arbitrary levels of nesting for hierarchical representations of `data`. For examples, see `test/yaml/two_level.yaml` and `test/schema/two_level.schema`. The program is run the same way.
1
2
2
-
`yamldoc` also includes support for a maximum of two levels deep hierarchical representations of `data`. For examples, see `test/yaml/two_level.yaml` and `test/schema/two_level.schema`. The program is run the same way.
3
+
### Example of Deeper Nesting
4
+
5
+
Here is an example of a YAML file with deeper nesting:
# Lines are split by <br /> in the actual output but we don't care about where
274
+
output=output.replace("<br />", "")
275
+
output=output.replace("\n", "")
276
+
sys.stdout=old_stdout
277
+
proper_markdown="""# Configuration Parameters Reference\n\nAny information about this page goes here.\n\n| Key | Value | Type | Information |\n| :-: | :-: | :-: | :-- |\n| `flat` | `"yes"` | string | This is a flat entry. |\n\n\n\n## `two`\n\nBut this is a two level thing.\n\n### Member variables:\n\n| Key | Value | Type | Information |\n| :-: | :-: | :-: | :-- |\n| `entry` | `"hi"` | [\'string\', \'number\'] | These can have documentation too. |\n\n\n\n## `three`\n\nThis is a three level thing.\n\n### Member variables:\n\n| Key | Value | Type | Information |\n| :-: | :-: | :-: | :-- |\n| `level_two` | | object | This is the second level. |\n\n\n\n#### `level_two`\n\nThis is the second level.\n\n##### Member variables:\n\n| Key | Value | Type | Information |\n| :-: | :-: | :-: | :-- |\n| `level_three` | `"hello"` | string | This is the third level. |"""
This package converts a YAML file into markdown, formatting values and associated metadata in a `doxygen`-like way. To get started, check out the [documentation](http://chrisbcole.me/yamldoc/) and [tutorials](http://chrisbcole.me/yamldoc/tutorial/).
17
+
18
+
## Installation
19
+
20
+
```sh
21
+
pip install yamldoc
22
+
```
23
+
24
+
This will install the python package, which contains a command line interface `yamldoc`. To see usage instructions, invoke the `--help` flag:
25
+
26
+
```sh
27
+
yamldoc -h
28
+
```
29
+
30
+
## Features and Supported Syntax
31
+
32
+
`yamldoc` does not support the full syntax of YAML, which is vast and complex. Instead, it supports a subset of YAML that is useful for documenting configuration files. This subset includes:
33
+
34
+
| Syntax | Supported | Description |
35
+
| --- | --- | --- |
36
+
| `key: value` | Yes | Basic key-value pairs. Values can be any type and are not subject to coercion. (i.e. `yes` will remain `yes` in `yamldoc` output. It will not be coerced to `True` as a YAML parser would. The goal of `yamldoc` is to be **transparent**, not feature complete. |
37
+
| `key: [value1, value2, ...]` | Yes | Arrays are understood by yamldoc if they are either listed on one line or each entry given on a new line with dashes to indicate entries. |
38
+
| Comments | Yes | Non-`yamldoc` comments are ignored. `yamldoc` comments are indicated by a special character (default `#'`) at the beginning of the line. `yamldoc` comments can be broken over as many lines as you like, they will be added together when the markdown is constructed. |
39
+
40
+
Things YAML does not support:
41
+
42
+
- Nested arrays past two levels of nesting. `yamldoc` will not parse nested arrays past two levels of nesting. [Issue #14](https://github.com/Chris1221/yamldoc/issues/14) tracks this request.
43
+
- Multi-line strings (unquoted or quoted scalars) indicated by `|` or `>` are not supported.
44
+
- Lists of dictionaries are not supported.
45
+
- Multiple documents in a single file are supported, but no special handling is done to separate them. It is assumed that each document is a separate configuration file.
46
+
- Complex mapping keys starting with `!!` or `?` are not supported. `yamldoc` will not parse complex mappings, tags, or explicit tags.
47
+
48
+
49
+
## Philosophy
50
+
51
+
Many programs and utilities use YAML ([YAML Ain't Markup Language](https://en.wikipedia.org/wiki/YAML)) as a human and machine readable interface to configuration parameters and other values. More broadly, many kinds of data can be stored in YAML with minimal effort from the user. However, often a configuration file accumulates a highly specific set of configurations marked up with vague, difficult to interpret comments. It is the goal of this package to provide an easy interface for developers to document data in their YAML files as well as the expected types from a [JSON YAML schema validator](https://json-schema-everywhere.github.io/yaml). Doing so will allow a transparent interface between the developer's expectations and the user's configurations.
52
+
53
+
### Specific Application to Snakemake
54
+
55
+
This package was designed specifically to document the possible configuration options of a [Snakemake](https://snakemake.readthedocs.io/en/stable/) pipeline. In this application, the developer of the pipeline encodes many different specific options that the user may configure at run time, but these are often poorly documented. When they are, it is easy for the documentation to fall out of sync with the actual options in the configuration file. `yamldoc` automatically documents all configuration paramters as well as taking types from a schema file. The package will also read any comments that are present above each paramter and insert them into a parameter table for easy reference.
56
+
57
+
For more details on using YAML to configure Snakemake pipelines, see [here](https://snakemake.readthedocs.io/en/stable/snakefiles/configuration.html).
58
+
59
+
## Example Files
60
+
61
+
For a minimal example of `yamldoc`, see the files in `/test/yaml` and `/test/schema`.
62
+
63
+
## Usage
64
+
65
+
For a basic report, point the command line interface to a YAML file.
66
+
67
+
```sh
68
+
yamldoc test/yaml/basic.yaml
69
+
```
70
+
71
+
You can also include type information from a schema file.
`yamldoc` defaults to using `#'` as a special marker, but you can choose this character yourself if you wish. Just set it on the command line at parse-time:
80
+
81
+
```sh
82
+
yamldoc test/yaml/basic.yaml -c "YOURCHAR"
83
+
```
84
+
85
+
`yamldoc` also includes support for certain special declarations in the schema file. Right now these include:
86
+
87
+
- `_yamldoc_title`: This specifies the overall title of the markdown page generated.
88
+
- `_yamldoc_description`: A description to follow the title.
89
+
90
+
These are picked out of the schema file and reported.
91
+
92
+
`yamldoc` has support for skipping individual entries in the reported markdown. Note this is seperate from adding comments that are not meta-data, these are respected and never reported. Skipping refers to actual entries in the YAML file. To skip an entry, add the skip character (by default, `#'!`) to the beginning of the line.
0 commit comments