onnx-mlir/doc/doc_check
chentong319 c45655413d
fix name of operator output in onnxop.inc and Operator.md (#62)
* fix name of operator output in onnxop.inc and Operator.md

* Update directive.py

Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
Co-authored-by: Tian Jin <tjingrant@gmail.com>
2020-02-06 20:54:03 +08:00
..
directive_impl [RFC] Doc-check utility. (#12) 2020-01-09 18:35:52 -05:00
test [RFC] Doc-check utility. (#12) 2020-01-09 18:35:52 -05:00
CMakeLists.txt Use a more compatible way to locate python interpreter executable. (#28) 2020-01-13 21:52:54 -05:00
README.md [RFC] Doc-check utility. (#12) 2020-01-09 18:35:52 -05:00
check.py [RFC] Doc-check utility. (#12) 2020-01-09 18:35:52 -05:00
directive.py fix name of operator output in onnxop.inc and Operator.md (#62) 2020-02-06 20:54:03 +08:00
doc_parser.py [RFC] Doc-check utility. (#12) 2020-01-09 18:35:52 -05:00
utils.py [RFC] Doc-check utility. (#12) 2020-01-09 18:35:52 -05:00

README.md

DocCheck

Goal

DocCheck provides a set of utilities to enforce invariant properties of artifacts (e.g., code snippets or output of execution) presented in the software documentation. They can be used to ensure that these artifacts are always compatible and up-to-date with the state of software development.

Directives

DocCheck provides a set of directives that can be used in documentations to enforce desired invariants. A directive is a comment with a specific format/syntax to communicate the intent to check certain invariants to the DocCheck checker. Generally, a directive has the following syntax in markdown:

[{directive}]: <> ({configuration})

Where {directive} specifies the type of invariance checking intended and {configuration} expresses the specific parameters of this directive. In general, a directive configuration is expressed using a python dictionary literal, but special shorthands exist for each directive individually.

same-as-file:

Use same-as-file directive to ensure that the code section following this directive is the same as a source file. This is useful primarily because testing code snippet in documentation directly is often impossible. However, unit tests can be written utilizing an exact copy of the code snippet content. We can use same-as-file directive to ensure the code snippet is always the same as its copy used in some unit tests,

same-as-file directive supports a convenient short-hand configuration format where the directive configuration can be fully specified using the name of the reference file to check against. For example, to ensure a code snippet is the same as a unit-tested file reference.cpp, use the following directive as shown in the documentation snippet:

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

[same-as-file]: <> (reference.cpp)
```cpp
#include<iostream>

using namespace std;

int main() {
    cout<<"Hello World";
    return 0;
}
```

In the canonical form of directive configuration (as a python dictionary literal), this directive supports these parameters in it:

ref (string): reference file to check against.

skip-doc (int): number of lines to skip when checking the documentation.

skip-ref (int): number of lines to skip when scanning the reference file.

For example, to ensure the following code snippet is the same as a unit-tested file reference.cpp, except for the first 2 lines of the code used in documentation, and the first 3 lines of code used in the reference file, the following directive configuration can be used:

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

[same-as-file]: <> ({"ref": "reference.cpp", "skip-doc": 2, "skip-ref": 3})
```cpp
// First line unique to documentation
// Second line unique to documentation
#include<iostream>

using namespace std;

int main() {
    cout<<"Hello World";
    return 0;
}
```