From 2b5d9a0769b01301fd02d877cf58b590fb158279 Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Mon, 27 Jul 2020 22:34:53 +0000 Subject: [PATCH 1/2] docs: create docfx yaml files and upload them This PR preserves the current behavior for uploading the HTML. It will generate docfx yaml files and upload them with docfx prefix. --- .kokoro/publish-docs.sh | 20 ++++++++++++++++++++ noxfile.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/.kokoro/publish-docs.sh b/.kokoro/publish-docs.sh index 322d8522..06d11132 100755 --- a/.kokoro/publish-docs.sh +++ b/.kokoro/publish-docs.sh @@ -43,3 +43,23 @@ cat docs.metadata # upload docs python3 -m docuploader upload docs/_build/html --metadata-file docs.metadata --staging-bucket "${STAGING_BUCKET}" + + +# docfx yaml files +nox -s docfx + +# create metadata. +python3 -m docuploader create-metadata \ + --name=$(jq --raw-output '.name // empty' .repo-metadata.json) \ + --version=$(python3 setup.py --version) \ + --language=$(jq --raw-output '.language // empty' .repo-metadata.json) \ + --distribution-name=$(python3 setup.py --name) \ + --product-page=$(jq --raw-output '.product_documentation // empty' .repo-metadata.json) \ + --github-repository=$(jq --raw-output '.repo // empty' .repo-metadata.json) \ + --issue-tracker=$(jq --raw-output '.issue_tracker // empty' .repo-metadata.json) \ + --serving-path="/python/docs/reference/$(jq --raw-output '.name // empty' .repo-metadata.json)/$(jq --raw-output '.distribution_name // empty' .repo-metadata.json)/latest" + +cat docs.metadata + +# upload docs +python3 -m docuploader upload docs/_build/html/docfx_yaml --metadata-file docs.metadata --destination-prefix docfx- --staging-bucket "${STAGING_BUCKET}" diff --git a/noxfile.py b/noxfile.py index 6a4c844b..8690d6af 100644 --- a/noxfile.py +++ b/noxfile.py @@ -155,3 +155,35 @@ def docs(session): os.path.join("docs", ""), os.path.join("docs", "_build", "html", ""), ) + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def docfx(session): + """Build the docfx yaml files for this library.""" + + session.install("-e", ".") + session.install("sphinx", "alabaster", "recommonmark", "sphinx-docfx-yaml") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-T", # show full traceback on exception + "-N", # no colors + "-D", + ( + "extensions=sphinx.ext.autodoc," + "sphinx.ext.autosummary," + "docfx_yaml.extension," + "sphinx.ext.intersphinx," + "sphinx.ext.coverage," + "sphinx.ext.napoleon," + "sphinx.ext.todo," + "sphinx.ext.viewcode," + "recommonmark" + ), + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) From 1c0fea1b2db96d9492bc58a037b2210f1cf910c9 Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Mon, 27 Jul 2020 23:02:24 +0000 Subject: [PATCH 2/2] lint --- noxfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/noxfile.py b/noxfile.py index 8690d6af..0b098cdf 100644 --- a/noxfile.py +++ b/noxfile.py @@ -156,6 +156,7 @@ def docs(session): os.path.join("docs", "_build", "html", ""), ) + @nox.session(python=DEFAULT_PYTHON_VERSION) def docfx(session): """Build the docfx yaml files for this library."""