Pages and categories
The creation of pages and categories in the documentation is considered in this section.
Page
The page is a typescript file that has ng-doc.page.ts
name and exports a configuration of type
.
You can create a page by creating a new file in your pages directory (the app src
folder by default) or by running the schematic command below (all available options you can find in the interface
):
Remember that the schematic command is called for the current directory, to run it for another directory, you need to specify the path to it in the
--path
parameter of the command.
ng g @ng-doc/builder:page "Installation"
This entity must be exported from the file by
default
, otherwise NgDoc will not load it. Multiple exports from the entity are not supported
Page description
The description of the page can be added as a JSDoc comment in the page configuration file. It will be displayed below the page header and will be common to all tabs of the page if they are present.
You can use markdown in the description.
Page tabs
The content of the page should be inside a markdown
file specified in the mdFile
property of the page configuration. You can also specify paths to multiple files, so NgDoc will display them as multiple tabs on the page.
Even when using tabs, you still need to use
index.md
, it will be used as the first tab and should not contain theroute
configuration. Therefore, if you navigate to the page,index.md
will be displayed by default.
The title
, icon
, route
, and other parameters for a tab can be specified within the file itself using metadata (check the
interface to see all available properties):
---
title: Nx
icon: Nx
route: nx
keyword: InstallationNxPage
---
## Running CLI commands
To run a CLI command, use the following command...
Category
Categories are used to structure your documentation and group pages. Every category is a typescript file that has ng-doc.category.ts
name and exports a configuration of type
.
You can create a category by creating a new file in your categories directory (the app src
folder by default) or by running the schematic command below (all available options you can find in the interface
):
Remember that the schematic command is called for the current directory, to run it for another directory, you need to specify the path to it in the
--path
parameter of the command.
ng g @ng-doc/builder:category "Getting Started"
This entity must be exported from the file by
default
, otherwise NgDoc will not load it. Multiple exports from the entity are not supported
import { NgDocCategory } from '@ng-doc/core';
const GettingStartedCategory: NgDocCategory = {
title: 'Getting Started',
};
export default GettingStartedCategory;
Adding pages to a category
To add a page to a category, you can use the category
field in the page configuration. Just import the category and put it in the category
field, like this:
Adding status badge for a page
You can add a different statuses for a page to display them in the sidebar. To do this, you need to use @status
tag in your page configuration file. The @status
tag should contain the status color that starts with :
and the status text. To see all available statuses, check the
type.