docs/README.md
We evaluated various existing solutions for documentation in the community and discussed their advantages and disadvantages in the issue #2651. Therefore, we propose to build a more modern and robust documentation system by integrating the Sphinx autodoc function and the Docusaurus framework.
- docs
- source
- en
- zh-Hans
- sidebars.json
- versions.json
- requirements-doc-test.txt
The documentation module structure is shown above:
sidebars.json: The sidebars.json defines the table of content for the tutorials. You need to update this file when a new doc is added/deleted.versions.json: The versions.json in the main branch in the latest commit will be used to control the versions to be displayed on our websiteWe believe that the combination of the existing systems can yield several advantages such as simplicity, usability and maintainability:
Therefore, we have built the ColossalAI-Documentation repository to integrate the features above.
You can contribute to the documentation by directly setting up a Pull Request towards the docs/source folder. There are several guidelines for documentation contribution.
You can add a Markdown file to the docs/source folder. You need to ensure that multi-language is supported in your PR. Let's assume that you want to add a file called your_doc.md`, your file structure will look like this.
- docs
- source
- en
- your_doc.md # written in English
- zh-Hans
- your_doc.md # written in Chinese
- sidebars.json # add your documentation file name here
Meanwhile, you need to ensure the sidebars.json is updated such that it contains your documentation file. Our CI will check whether documentation exists for all languages and can be used to build the website successfully.
Every documentation is tested to ensure it works well. You need to add the following line to the bottom of your file and replace $command with the actual command. Do note that the markdown will be converted into a Python file. Assuming you have a demo.md file, the test file generated will be demo.py. Therefore, you should use demo.py in your command, e.g. python demo.py.
<!-- doc-test-command: $command -->
Meanwhile, only code labeled as a Python code block will be considered for testing.
```python
print("hello world")
```
Lastly, if you want to skip some code, you just need to add the following annotations to tell docer to discard the wrapped code for testing.
<!--- doc-test-ignore-start -->
```python
print("hello world")
```
<!--- doc-test-ignore-end -->
If you have any dependency required, please add it to requirements-doc-test.txt for pip and conda-doc-test-deps.yml for Conda.
Lastly, you may want to include the API documentation for a class/function in your documentation for reference.
We support autodoc to extract the docstring and transform it into a Web element for an elegant display.
You just need to add {{ autodoc:<mod-name> }} in your markdown as a single line. An example is given below and you can see the outcome in this PR.
{{ autodoc:colossalai.legacy.amp.apex_amp.convert_to_apex_amp }}