Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Enable docs versioning for 0.16.16 #8125

Merged
merged 17 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ci/azure-pipelines-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,6 @@ stages:
displayName: 'Use Python 3.8'

- script: cd docs/docusaurus && yarn install && bash ../build_docs
name: TestBuildDocs
displayName: TestBuildDocs
env:
NODE_OPTIONS: --max_old_space_size=4096
19 changes: 10 additions & 9 deletions docs/docusaurus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ To add a new version, follow these steps:
4. Install API docs dependencies `pip install -r docs/sphinx_api_docs_source/requirements-dev-api-docs.txt`
5. Build API docs `invoke api-docs` from the repo root.
6. Run `yarn install` from `docs/docusaurus/`.
7. Run `yarn build` from `docs/docusaurus/`.
8. Create the version e.g. `yarn docusaurus docs:version 0.15.50` from `docs/docusaurus/`.
9. Pull down the version file (see `docs/build_docs` for the file, currently https://superconductive-public.s3.us-east-2.amazonaws.com/oss_docs_versions.zip)
10. Unzip and add your newly created versioned docs via the following:
11. Copy the version you built in step 4 from inside `versioned_docs` in your repo to the `versioned_docs` from the unzipped version file.
12. Copy the version you built in step 4 from inside `versioned_sidebars` in your repo to the `versioned_sidebars` from the unzipped version file.
13. Add your version number to `versions.json` in the unzipped version file.
14. Zip up `versioned_docs`, `versioned_sidebars` and `versions.json` and upload to the s3 bucket (see `docs/build_docs` for the bucket name)
15. Once the docs are built again, this zip file will be used for the prior versions.
7. Temporarily change onBrokenLinks: 'throw' to onBrokenLinks: 'warn' in `docusaurus.config.js` to allow the build to complete even if there are broken links.
8. Run `yarn build` from `docs/docusaurus/`.
9. Create the version e.g. `yarn docusaurus docs:version 0.15.50` from `docs/docusaurus/`.
10. Pull down the version file (see `docs/build_docs` for the file, currently https://superconductive-public.s3.us-east-2.amazonaws.com/oss_docs_versions.zip)
11. Unzip and add your newly created versioned docs via the following:
12. Copy the version you built in step 4 from inside `versioned_docs` in your repo to the `versioned_docs` from the unzipped version file.
13. Copy the version you built in step 4 from inside `versioned_sidebars` in your repo to the `versioned_sidebars` from the unzipped version file.
14. Add your version number to `versions.json` in the unzipped version file.
15. Zip up `versioned_docs`, `versioned_sidebars` and `versions.json` and upload to the s3 bucket (see `docs/build_docs` for the bucket name)
16. Once the docs are built again, this zip file will be used for the prior versions.
2 changes: 1 addition & 1 deletion docs/docusaurus/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
tagline: 'Always know what to expect from your data.',
url: 'https://docs.greatexpectations.io', // Url to your site with no trailing slash
baseUrl: '/',
onBrokenLinks: 'throw',
onBrokenLinks: 'warn', // Temporary, please set this back to 'throw' when we have fixed all broken links.
onBrokenMarkdownLinks: 'warn',
favicon: '/img/gx-mark.png',
organizationName: 'great-expectations',
Expand Down
12 changes: 10 additions & 2 deletions docs/prepare_prior_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ def _use_relative_path_for_imports_substitution_path_starting_with_forwardslash(
e.g. `import TechnicalTag from '../../term_tags/_tag.mdx';`
instead of `import TechnicalTag from '/docs/term_tags/_tag.mdx';`

Also if the path starts with / and the relative path is the same directory, then we will
replace the path with a dot. E.g. `import CLIRemoval from '/components/warnings/_cli_removal.md'` ->
`import CLIRemoval from './components/warnings/_cli_removal.md'`

Args:
contents: String to perform substitution.
path_to_versioned_docs: e.g. "docs/docusaurus/versioned_docs/version-0.14.13/"
Expand All @@ -291,9 +295,13 @@ def _use_relative_path_for_imports_substitution_path_starting_with_forwardslash(
r"(?P<import>import .* from ')(?P<slash_docs>/docs/)(?P<rest>.*)"
)
contents = re.sub(pattern, rf"\g<import>{dotted_relative_path}/\g<rest>", contents)
return contents

pass
contents = contents.replace(
"'/components/warnings/_cli_removal.md'",
"'./components/warnings/_cli_removal.md'",
)

return contents


if __name__ == "__main__":
Expand Down
18 changes: 4 additions & 14 deletions docs/prepare_to_build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
# git pull to get the latest tags
git pull

print_orange_header "Copying previous versioned docs"
curl "https://superconductive-public.s3.us-east-2.amazonaws.com/oss_docs_versions_20230404.zip" -o "oss_docs_versions.zip"
S3_URL="https://superconductive-public.s3.us-east-2.amazonaws.com/oss_docs_versions_20230615.zip"
print_orange_header "Copying previous versioned docs from $S3_URL"
curl $S3_URL -o "oss_docs_versions.zip"
unzip -oq oss_docs_versions.zip -d .
rm oss_docs_versions.zip

Expand All @@ -29,19 +30,8 @@ for version in $VERSIONS; do
done


print_orange_header "Updating versioned code and docs..."
print_orange_header "Updating versioned code and docs via prepare_prior_versions.py..."

print_orange_header "Updating filepath in versioned docs"
# This is done in prepare_prior_versions.py
# Update filepath in versioned docs if they are using the old linenumber style of file=<filepath>L<lineno>
# by adding the correct versioned_code filepath e.g. versioned_code/version-0.14.13/<filepath>

print_orange_header "Updating snippet names in versioned docs and code"
# This is done in prepare_prior_versions.py
# Update snippet names in versioned docs if they are using the style of name="<snippet_name>"
# by prepending the version e.g. name="version-0.15.50 <original_snippet_name>"
# This is done in the docs and code so that the snippet processing tool can match up the correct snippet
# based on the version of the code file that existed when the document was released.
cd ../
python prepare_prior_versions.py
cd docusaurus
Expand Down
40 changes: 40 additions & 0 deletions tests/docs/test_prepare_prior_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,43 @@ def test__use_relative_path_for_imports_substitution_path_starting_with_forwards
"""

assert updated_contents == expected_contents


@pytest.mark.unit
def test__use_relative_path_for_imports_substitution_path_starting_with_forwardslash_same_directory():
"""Tests for relative path where the imported file is in the same directory as the file being updated."""

contents = """---
id: glossary
title: "Glossary of Terms"
---

import CLIRemoval from '/components/warnings/_cli_removal.md'

<CLIRemoval />
"""

path_to_versioned_docs = pathlib.Path(
"docs/docusaurus/versioned_docs/version-0.16.16/"
)
file_path = pathlib.Path(
"docs/docusaurus/versioned_docs/version-0.16.16/glossary.md"
)

updated_contents = (
_use_relative_path_for_imports_substitution_path_starting_with_forwardslash(
contents, path_to_versioned_docs, file_path
)
)

expected_contents = """---
id: glossary
title: "Glossary of Terms"
---

import CLIRemoval from './components/warnings/_cli_removal.md'

<CLIRemoval />
"""

assert updated_contents == expected_contents