Generation Pipeline
Introduction
As of now, Docfx does not natively support the generation of multi-language and multi-version documentation. To address this limitation, the Stride team has developed a PowerShell script. Initially, separate scripts were created for each language; however, these have since been consolidated into a single script named BuildDocs.ps1. This unified script is capable of generating documentation in all supported languages.
The script serves two main purposes:
- It features a non-interactive mode, utilized by the Continuous Integration/Continuous Deployment (CI/CD) pipeline to automatically generate documentation for all languages and the most recent version, eliminating the need for user intervention.
- It also offers an interactive command-line UI, allowing users to select which languages they wish to generate documentation for.
A Simplified Overview
Here's a straightforward explanation of how the documentation generation process works.
The /en folder serves as the repository for the primary documentation files. When documentation for another language (e.g., Japanese) is built, the files from /en are copied over to a temporary folder, for example, /jp-tmp. This ensures that the non-English versions will contain all the files present in the /en folder. Files that have been translated (found in folders like /jp) will overwrite their English counterparts in the temp folder /jp-tmp.
Docfx is invoked multiple times, once for each language, to create the documentation. The generated documents are stored in the _site folder, organized according to the latest version information obtained from version.json. For example:
/_site/4.1/en
/_site/4.1/jp
Docfx Files Processed
This section outlines the file processing carried out by Docfx during the documentation generation:
- Table of Contents (TOC) Files: 7 files processed
- Assets: 1620 items (images, videos, etc.) included
- Conceptual Files: 358 files processed, resulting in 304 HTML files
- Warnings (No API Metadata): 44 instances encountered
- Warnings (API Metadata): 200 instances of missing or incorrect references
- API Files: 2825 files processed, resulting in 2133 HTML files
Docs Build Workflow
In this part, we elaborate on the individual steps involved in the documentation build workflow for the Stride Docs project.
- Start
- Initiates the workflow by reading the
$BuildAllparameter.- If set to 'Yes', it proceeds to generate all languages and the Stride API automatically, which is particularly useful for CI/CD.
- If set to 'No', it will prompt the user to select languages through an interactive command-line UI.
- Sets the
$Versionparameter based on the-Versioncommand-line argument or fetches it fromversion.jsonif the argument is not provided.
- Initiates the workflow by reading the
- Read-LanguageConfigurations
- Reads
languages.jsonto identify which languages should be generated.
- Reads
- BuildAll
- Pre-configures some variables for non-interactive mode, effectively skipping the
Get-UserInputstep.
- Pre-configures some variables for non-interactive mode, effectively skipping the
- Get-UserInput
- In interactive mode, this step prompts the user to choose the languages to generate, as well as whether to launch a local web server.
- Ask-IncludeAPI
- Further queries if the user wants the Stride API included in the documentation build.
- Ask-UseExistingAPI
- Queries if the user wants to re-use already generated Stride API yml files.
- Start-LocalWebsite
- If selected, launches a local web server to host the generated website.
- Generate-APIDoc
- Executes
docfx.exeto generate the metadata needed for the Stride API documentation.
- Executes
- Remove-APIDoc
- Removes the generated API metadata.
- Build-EnglishDoc
- Uses
docfx.exeto build the English documentation, incorporating the Stride API documentation if metadata is available.
- Uses
- PostProcessing Steps
- PostProcessing-FixingSitemap
- Adjusts the
sitemap.xmlto use '/latest/en' paths, allowing the most current version to maintain a consistent URL.
- Adjusts the
- PostProcessing-Fixing404AbsolutePath
- Modifies asset (CSS, JS, ) paths in
404.htmlto be absolute, as required by IIS for 404 page.
- Modifies asset (CSS, JS, ) paths in
- Copy-ExtraItems
- Copies additional items like
versions.json,web.config,ReleaseNotes.mdandrobots.txt, while also updating the%deployment_version%parameter in theweb.configfile.
- Copies additional items like
- PostProcessing-FixingSitemap
- Build-AllLanguagesDocs
- Iterates over all selected languages and triggers the
Build-NonEnglishDocfunction for each.
- Iterates over all selected languages and triggers the
- Build-NonEnglishDoc
- Executes
docfx.exeto compile non-English documentation, incorporating Stride API documentation if metadata is present.
- Executes
- PostProcessing-DocFxDocUrl
- Adjusts HTML tags and GitHub links, removing any
_tmpsuffixes. Also updates GitHub links to English if the translation is unavailable.
- Adjusts HTML tags and GitHub links, removing any
Workflow Diagram
%% Define styles
%% Main Graph
graph TB
%% Nodes
Start[Start]
A[Read-LanguageConfigurations]
B{BuildAll}
C[Get-UserInput]
D[Generate-APIDoc]
E{Ask-IncludeAPI}
E1{Ask-UseExistingAPI}
End[End]
F[Start-LocalWebsite]
G[Cancel]
H[Remove-APIDoc]
M{isEnLanguage or isAllLanguages}
N[Build-EnglishDoc]
O[PostProcessing-FixingSitemap]
O1[PostProcessing-Fixing404AbsolutePath]
P[Copy-ExtraItems]
R{isAllLanguages}
S[Build-AllLanguagesDocs]
T[Build-NonEnglishDoc]
Y[PostProcessing-DocFxDocUrl]
Z[End]
%% Edges
Start --> A --> B
B -->|Yes| D
B -->|No| C
subgraph User Interaction
C --> E
E -->|Yes| E1
E -->|No| H
C --> F --> F1{{docfx serve}}
C --> G
end
F1 --> End
G --> End
E1 -->|No| D
E1 -->|Yes| M
subgraph Documentation Generation
H --> M
D --> D1{{docfx metadata}} --> M
M -->|Yes| N
M -->|No| R
N --> DocFX{{docfx build}} --> O --> O1--> P
P --> R
R -->|Yes| S
R -->|No| T
S --> T
T --> X{{docfx build}}
X --> X1{{docfx pdf}}
X1 --> Y
Y --> Z
end