This directory builds the documentation site at
https://dashscope.github.io/dashscope-sdk-java/ (MkDocs Material, bilingual, with generated
Javadoc mounted under /api/). This file is excluded from the site — it is for maintainers.
Shared Python/Java site structure: documentation template.
docs/
├── en/ # English — the canonical source of every page
│ ├── index.md quickstart.md features.md migrating.md legacy.md reference.md
│ ├── examples.md develop.md release-notes.md about.md
│ ├── reference/ # task-oriented index pages for generated Javadoc
│ └── guides/ # chat, async, multimodal, embeddings-rerank, images-videos, audio,
│ # files-finetunes, agentstudio, tokenization, local-mock, errors, configuration
├── zh/ # Simplified Chinese — same file names, translated prose
├── overrides/ # Material theme overrides
├── stylesheets/ # extra.css
├── javadoc/ # material-bridge.css (appended to the Javadoc stylesheet)
├── hooks.py # injects sdk_version (parsed from the root pom.xml) into config.extra
├── main.py # macros module: {{ sdk_version }} + {{ release_notes }} (GitHub Releases table)
└── serve.sh # local preview: Javadoc + mkdocs serve
Rules:
- English first: write or update
docs/en/<page>.md, then mirror the change indocs/zh/<page>.md(same relative path). The i18n plugin usesdocs_structure: folder; a page missing underzh/falls back to the English build, so never leave a translation half-done — either ship both or neither. - Code blocks stay identical between languages except for comments/output strings.
- Full runnable examples are embedded, never copied: the "Full runnable example
(auto-synced)" collapsibles use
pymdownx.snippets(--8<-- "examples/...") to include the real example source at build time.check_paths: truefails the build if a referenced file is missing or renamed, so embedded code can never drift from the CI-verifiedexamples/project. When adding a guide, embed its source example(s) the same way; keep inline snippets short and instructional. - Every API claim must be traceable to
src/main/javaor a dry-run-verified example underexamples/— do not document methods that do not exist. {{ sdk_version }}renders the rootpom.xmlversion; use it instead of hard-coding version numbers in install snippets.{{ release_notes }}(release-notes.md only) renders the five latest published GitHub Releases as a table, fetched once per build (drafts excluded). If the API is unreachable it degrades to a plain link — the build never fails offline. CI passesGITHUB_TOKENonly to lift the anonymous rate limit; publishing a release refreshes the table on the next docs build.
There is a single nav in mkdocs.yml with English titles. Chinese titles come from
plugins.i18n.languages[zh].nav_translations. When adding a page:
- Add the page to
nav(English title). - Add the same English title → Chinese title mapping to
nav_translations.
Non-site files are kept out of the build by mkdocs-exclude
(README.md, serve.sh, hooks.py, main.py, javadoc/*, overrides/*). docs/api/ is
not excluded: when present (after docs/serve.sh), MkDocs copies it verbatim so the
Javadoc is reachable at /api/ in local preview; CI attaches it to site/api/ post-build.
# one-time: Python deps (mkdocs 1.x + Material + i18n + macros + jieba)
pip3 install --user -r requirements-doc.txt
# guides only — strict mode fails on any warning (broken links, missing nav, …)
python3 -m mkdocs build --strict
# full preview incl. Javadoc under /api/ (needs JDK 17; override with JDK17=/path/to/jdk17)
bash docs/serve.sh # then open http://127.0.0.1:8000docs/api/ is generated output (gitignored); never edit or commit it.
# run with JDK 17
mvn -Pdocs -DskipTests -Dgpg.skip=true generate-sources javadoc:javadoc- The
docsMaven profile delombokssrc/main/javaintotarget/generated-sources/delombok(so builder methods appear in the docs), then runsmaven-javadoc-pluginovercom.alibaba.dashscopeincludinglegacy_2x, withdoclint noneand parsing level 17 (shipped bytecode stays Java 8). - Output lands in
target/apidocs.docs/serve.shand the CI workflow appenddocs/javadoc/material-bridge.csstotarget/apidocs/stylesheet.cssand copy the tree into the site under/api/(the plugin'saddStylesheetsoption is unreliable, hence the post-hoc append).
.github/workflows/docs.yml:
- Pull requests touching docs/site inputs: strict build only (no deploy).
- Push to
main/master: build (Javadoc + strict MkDocs), attach Javadoc undersite/api/, deploy to GitHub Pages viaactions/deploy-pages. - Release published: a dispatcher job re-runs the workflow on
mainso the published site always reflects the default branch.
One-time repository setup: Settings → Pages → Build and deployment → Source:
GitHub Actions. No gh-pages branch is used.