Add documentation
Now that we have completed the code, it's time to add the documentation for your route. Open the appropriate file in the document (/website/docs), which in this example is website/docs/routes/programming.mdx
.
In order to preview the documentation in real-time, you need to install the dependencies for the documentation. Run the following command in the website
directory:
- pnpm
- yarn
- npm
pnpm i
yarn
npm install
You can now preview the documentation in real-time by running the following command in the website
directory:
- pnpm
- yarn
- npm
pnpm run start
yarn start
npm run start
You cannot switch to other languages in development mode. This is a technical limitation from Docusaurus.
The documentation is written in MDX v3 and rendered with Docusaurus v3.
To add documentation to your route, use the Route
React component. It works like HTML tag. The following are the most commonly used component properties:
author
: The route maintainer(s), separated by a single space. It should be the same asmaintainer.js
example
: The route example, with a leading/
path
: The route path, which should be the same as the key inmaintainer.js
with the namespace. In the above example, it is/github/issue/:user/:repo?
paramsDesc
: The route parameter description, in an array of strings that support Markdown.- The description must follow the order in which they appear in the path.
- The number of description should match with the number of parameters in
path
. If you miss a description, the build will fail. - Route parameters ending with
?
,*
or+
will be automatically marked asoptional
,zero or more
orone or more
, respectively. - Route parameters without a suffix are marked as
required
- There's no need to explicitly mention the necessity of path parameters again.
- If a parameter is optional, make sure to mention the default value.
Documentation examplesβ
Repo Issues (No parameter)β
<Route author="HenryQW" example="/sspai/series" path="/sspai/series" />
Repo Issues (Multiple parameters)β
<Route author="HenryQW" example="/github/issue/DIYgod/RSSHub" path="/github/issue/:user/:repo?" paramsDesc={['GitHub username', 'GitHub repo name, `RSSHub` by default']} />
π‘ Example: https://rsshub.mlj-dragon.cn/github/issue/DIYgod/RSSHub
π Route: /github/issue/:user/:repo?
βοΈ Parameters:
user
, required - GitHub usernamerepo
, optional - GitHub repo name,RSSHub
by default
Keyword (Description with table)β
<Route author="DIYgod" example="/pixiv/search/Nezuko/popular/2" path="/pixiv/search/:keyword/:order?/:mode?" paramsDesc={['keyword', 'rank mode, empty or other for time order, `popular` for popular order, `date` by default', 'filte R18 content, see table below, empty by default']}>
| only not R18 | only R18 | no filter |
| ------------ | -------- | -------------- |
| safe | r18 | empty or other |
</Route>
π‘ Example: https://rsshub.mlj-dragon.cn/pixiv/search/Nezuko/popular/2
π Route: /pixiv/search/:keyword/:order?/:mode?
βοΈ Parameters:
keyword
, required - keywordorder
, optional - rank mode, empty or other for time order,popular
for popular order,date
by defaultmode
, optional - filte R18 content, see table below, empty by default
only not R18 | only R18 | no filter |
---|---|---|
safe | r18 | empty or other |
Custom containersβ
If you'd like to provide additional information about a particular route, you can use these custom containers:
<details>
<summary>Click to expand</summary>
This is a detail block. Title is optional and does not support Markdown.
</details>
:::note
This is a note.
:::
:::tip[Tips title]
Title is optional.
:::
:::info
Supprts Markdown.
:::
:::warning
Add a empty line around the starting and ending directive `:::`
:::
:::danger
Otherwise the content may not be rendered properly.
:::
Details
Click to expand
This is a detail block. Title is optional and does not support Markdown.This is a note.
Title is optional.
Supprts Markdown.
Add a empty line around the starting and ending directive :::
Otherwise the content may not be rendered properly.
Other componentsβ
In addition to the aforementioned component properties, there are several other properties you can use to provide more information about your route:
anticrawler
: set to1
if the target website has an anti-crawler mechanism.puppeteer
: set to1
if the feed uses puppeteer.radar
: set to1
if the feed has a radar rule.configRequired
: set to1
if the feed requires extra configuration through environment variables.supportBT
: set to1
if the feed supports BitTorrent.supportPodcast
: set to1
if the feed supports podcasts.supportScihub
: set to1
if the feed supports Sci-Hub.
By using these properties, you can provide valuable information to users and make it easier for them to understand and use your route. Adding these properties to your route documentation will add a badge in front of it.
<Route author="HenryQW" example="/github/issue/DIYgod/RSSHub" path="/github/issue/:user/:repo?" paramsDesc={['GitHub username', 'GitHub repo name, `RSSHub` by default']} anticrawler="1" puppeteer="1" radar="1" configRequired="1" supportBT="1" supportPodcast="1" supportScihub="1" />
π¨ Strict anti-crawlingπ Support BTποΈ Support Podcastπ§ͺ Support Sci-Hubπ Rely on PuppeteerβοΈ Config requiredπ Support Radar
π‘ Example: https://rsshub.mlj-dragon.cn/github/issue/DIYgod/RSSHub
π Route: /github/issue/:user/:repo?
βοΈ Parameters:
user
, required - GitHub usernamerepo
, optional - GitHub repo name,RSSHub
by default
Other things to keep in mindβ
- When documenting a route, use a level 3 heading (
###
). If the route documentation doesn't have a main section heading, add a level 2 heading (##
). - Leave a blank line between each heading and the following content. This will help ensure that your documentation can be built successfully.
- If the documentation contains a large table, it is suggested to put it inside a details container
- Components can be written in two ways: as a self-closing tag (
<Route .../>
) or as a pair of tags (<Route>...</Route>
). - Remember to close the tag!
- Don't forget to run the following command in the root directory of the project to check and format your code before committing and submitting a merge request:
- pnpm
- yarn
- npm
pnpm run format
yarn format
npm run format