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:
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
This section outlines the file processing carried out by Docfx during the documentation generation:
In this part, we elaborate on the individual steps involved in the documentation build workflow for the Stride Docs project.
$BuildAll parameter.$Version parameter based on the -Version command-line argument or fetches it from version.json if the argument is not provided.languages.json to identify which languages should be generated.Get-UserInput step.docfx.exe to generate the metadata needed for the Stride API documentation.docfx.exe to build the English documentation, incorporating the Stride API documentation if metadata is available.sitemap.xml to use '/latest/en' paths, allowing the most current version to maintain a consistent URL.404.html to be absolute, as required by IIS for 404 page.versions.json, web.config, ReleaseNotes.md and robots.txt, while also updating the %deployment_version% parameter in the web.config file.Build-NonEnglishDoc function for each.docfx.exe to compile non-English documentation, incorporating Stride API documentation if metadata is present._tmp suffixes. Also updates GitHub links to English if the translation is unavailable.%% 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