English | 中文
Shared Python/Java site structure: documentation template.
The documentation is a MkDocs Material project (the same stack as the FastAPI
docs): site configuration lives in mkdocs.yml at the repository root, page
sources live in docs/, covering the dashscope 2.0 API. The API reference is
generated automatically from source docstrings via mkdocstrings (::: module.Class
directives); guides and the quickstart are plain Markdown.
The site is bilingual: English is the default language (docs/en/,
published at the site root) and Simplified Chinese (docs/zh/, published
under /zh/), with a language selector in the header (provided by the
mkdocs-static-i18n plugin, the same approach FastAPI uses).
-
Multi-language directory conventions
docs/ ├── en/ # default language (English), mirrors the same subtree │ ├── index.md / features.md / quickstart.md / cli.md │ ├── examples.md / develop.md / about.md / release-notes.md │ ├── reference.md # API overview │ ├── guides/ └ reference/ ├── zh/ # Chinese translation, one-to-one with en/ ├── overrides/ # Material template override (per-page action block) ├── hooks.py # build hook: inject SDK version from dashscope/version.py └── assets/ + stylesheets/ # logo and custom CSS- New pages: write the English original in
docs/en/first, then add the same-named translation indocs/zh/; untranslated pages automatically fall back to the English original. - Navigation titles are written in English in the
navsection ofmkdocs.yml; Chinese titles are mapped through the i18n plugin'snav_translations. - The
:::directives on API reference pages are identical in both languages (docstrings themselves are English); the zh version translates headings and introductions, the API body stays English. - Cross-page auto-references (autorefs) are configured with
resolve_closest: true, so references inside Chinese pages point to Chinese pages and English pages point to English pages. docs/overrides/main.htmloverrides the Material template to render the per-page action block (report issue / contribute); the directory is excluded from the site viaexclude_docs.
- New pages: write the English original in
-
Local build & preview
# From the repository root: python -m pip install -r requirements-doc.txt python -m pip install -e . mkdocs serve # Open http://127.0.0.1:8000 in a browser for live preview # Or build the static site only: mkdocs build # output in site/
site/is git-ignored and regenerated on every build. -
CI publishing
.github/workflows/docs.ymlrunsmkdocs build --strictas a check on every PR (any warning or broken reference fails the build) and on pushes tomainthat touchdocs/,dashscope/,mkdocs.ymlorrequirements-doc.txt. Pushes tomainadditionally deploy the HTML to GitHub Pages. Publishing a GitHub Release dispatches another docs run onmainto refresh the release-notes table. Manual runs onmainalso deploy; manual runs on other refs only validate the build. Deployments share one concurrency group, while PR checks and Release dispatchers stay separate. Thegithub-pagesenvironment can keep its deployment policy restricted to themainbranch.One-time repository setup required: Settings → Pages → Build and deployment → Source = "GitHub Actions". After the first successful deployment the site is available at
https://<owner>.github.io/<repo>/. -
Docstring format
We use Google-style docstrings as the standard. References:
- Google Python style guide, docstrings link
- Google docstring examples link
- Example: torch.nn.modules.conv link
- Using a load function as an example:
def load(file, file_format=None, **kwargs): """Load data from json/yaml/pickle files. This method provides a unified api for loading data from serialized files. Args: file (str or :obj:`Path` or file-like object): Filename or a file-like object. file_format (str, optional): If not specified, the file format will be inferred from the file extension, otherwise use the specified one. Currently supported formats include "json", "yaml/yml". Examples: >>> load('/path/of/your/file') # file is stored in disk >>> load('https://path/of/your/file') # file is stored on internet >>> load('oss://path/of/your/file') # file is stored in petrel Returns: The content from the file. """