docs/docusaurus/README.md
This documentation site is built using Docusaurus 2, a modern static website generator.
https://docusaurus.io/docs/installation#requirements
Follow the CONTRIBUTING_CODE guide in the great_expectations repository to install dev dependencies.
Then run the following command from the repository root to install the rest of the dependencies and build documentation locally (including prior versions) and start a development server:
invoke docs
Once you've run invoke docs once, you can run invoke docs --start to start the development server without copying and building prior versions.
To enable certain features during local development, you may need to set environment variables.
.env file in the docs/docusaurus/ directory by copying the example file:
cp docs/docusaurus/.env.example docs/docusaurus/.env
docs/docusaurus/.env file and add your specific API keys or other necessary values.This .env file is included in .gitignore and should not be committed to version control.
standard.js is used to lint the project. Please run the linter before committing changes.
invoke docs --lint
To build a static version of the site, this command generates static content into the build directory. This can be served using any static hosting service.
invoke docs --build
Deployment is handled via Netlify.
The following are a few details about other files Docusaurus uses that you may wish to be familiar with.
sidebars.js: JavaScript that specifies the sidebar/navigation used in docs pagesstatic: static assets used in docs pages (such as CSS) live heredocusaurus.config.js: the configuration file for Docusaurusbabel.config.js: Babel config file used when buildingpackage.json: dependencies and scriptsyarn.lock: dependency lock file that ensures reproducibilitysrc/: global components live heredocs/: Current version of docsversioned_docs/: Older versions of docs live here. These are copies of docs/ from the moment when docs invoke --version=<VERSION> was run.versioned_sidebars/: Older versions of sidebars live here. Similar to versioned_docs/sitemap.xml is not in the repo since it is built and uploaded by a netlify plugin during the documentation build process.
This project uses Docusaurus's swizzling feature to customize theme components. Swizzling allows us to override default Docusaurus components with our own implementations.
Ejected components are fully copied into the project, giving complete control but requiring manual updates when Docusaurus upgrades.
src/theme/CodeBlock/)code-block-hide-line class (configured via Prism magic comments)Wrapped components import the original via @theme-original and add custom behavior. These are safer and typically require less maintenance during upgrades.
src/theme/Admonition/)src/theme/DocSidebarItems/)src/theme/SearchPage/)src/theme/DocCategoryGeneratedIndexPage/)src/theme/NavbarItem/)DropdownNavbarItem, DocsVersionDropdownNavbarItem, ComponentTypessrc/theme/Navbar/ColorModeToggle/)When upgrading Docusaurus, follow these steps:
Review the Changelog: Check the Docusaurus changelog for breaking changes related to swizzled components.
Test Wrapped Components: Wrapped components should continue working, but test them to ensure compatibility.
Manually Update Ejected Components:
Swizzle Command Reference: To re-swizzle a component (useful for seeing what changed):
cd docs/docusaurus
npm run swizzle @docusaurus/theme-classic <ComponentName> -- --danger
Note: This will show you the latest version, but don't overwrite your customizations without careful review.
Testing Checklist:
To add a new version, follow these steps:
pip install -c constraints-dev.txt -e ".[test]" and pip install pysparkpip install -r docs/sphinx_api_docs_source/requirements-dev-api-docs.txtinvoke docs version=<MAJOR.MINOR> (substituting your new version numbers)versioned_docs/, versioned_sidebars/ and the change in versions.json to version controlsequenceDiagram
Participant Code
Participant SphinxBuild as temp_sphinx_api_docs_build_dir/
Participant Docusaurus as docs/docusaurus
Participant DocsBuild as docs/docusaurus/build
Participant Netlify
loop versioning
% invoke api-docs
Code ->> SphinxBuild: sphinx generated html
activate SphinxBuild
SphinxBuild ->> Docusaurus: html converted to .md and store in docs/docusaurus/docs/reference/api
deactivate SphinxBuild
Code ->> Docusaurus: yarn docusaurus docs:version
end
loop invoke docs --build
% invoke api-docs
Code ->> SphinxBuild: sphinx generated html
activate SphinxBuild
SphinxBuild ->> Docusaurus: html converted to .md and store in docs/docusaurus/docs/reference/api
deactivate SphinxBuild
% yarn docusaurus build
activate DocsBuild
Docusaurus ->> DocsBuild: build docs and versioned_*
DocsBuild ->> Netlify: Deploy
deactivate DocsBuild
end