Code blocks and snippets
DocStatic provides two ways to include code in your documentation. Both support syntax highlighting.
Code blocks
- Click the Code Block icon in the rich text editor.
- Click the language list and select or search for a language.
- Enter your code in the box.
Example:
This is some plain text.
Code snippets
- Select Code Snippet from the Embed list.
- Give it a Title.
- Select a Language.
- Choose a file from the list. The list is populated with all the files in the reuse/code/ folder every time you run the dev server or do a build.
Example:
Example Title
<div>
<p>Example</p>
</div>
The advantage of using code snippets is that there is a physical file that can be unit tested.