Skip to content

Latest commit

 

History

History

docs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Documentation Maintenance Guide

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.

Layout & bilingual convention

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 in docs/zh/<page>.md (same relative path). The i18n plugin uses docs_structure: folder; a page missing under zh/ 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: true fails the build if a referenced file is missing or renamed, so embedded code can never drift from the CI-verified examples/ 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/java or a dry-run-verified example under examples/ — do not document methods that do not exist.
  • {{ sdk_version }} renders the root pom.xml version; 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 passes GITHUB_TOKEN only to lift the anonymous rate limit; publishing a release refreshes the table on the next docs build.

Navigation

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:

  1. Add the page to nav (English title).
  2. 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.

Local build & preview

# 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:8000

docs/api/ is generated output (gitignored); never edit or commit it.

Javadoc generation

# run with JDK 17
mvn -Pdocs -DskipTests -Dgpg.skip=true generate-sources javadoc:javadoc
  • The docs Maven profile delomboks src/main/java into target/generated-sources/delombok (so builder methods appear in the docs), then runs maven-javadoc-plugin over com.alibaba.dashscope including legacy_2x, with doclint none and parsing level 17 (shipped bytecode stays Java 8).
  • Output lands in target/apidocs. docs/serve.sh and the CI workflow append docs/javadoc/material-bridge.css to target/apidocs/stylesheet.css and copy the tree into the site under /api/ (the plugin's addStylesheets option is unreliable, hence the post-hoc append).

CI publishing

.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 under site/api/, deploy to GitHub Pages via actions/deploy-pages.
  • Release published: a dispatcher job re-runs the workflow on main so 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.