diff --git a/owl-bot-staging/gcp-sphinx-docfx-yaml/gcp-sphinx-docfx-yaml/gcp-sphinx-docfx-yaml.txt b/owl-bot-staging/gcp-sphinx-docfx-yaml/gcp-sphinx-docfx-yaml/gcp-sphinx-docfx-yaml.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/gcp-sphinx-docfx-yaml/.gitignore b/packages/gcp-sphinx-docfx-yaml/.gitignore new file mode 100644 index 000000000000..dd0c769fb53a --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/.gitignore @@ -0,0 +1,65 @@ +*.py[cod] +*.sw[op] + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +eggs +.eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 +__pycache__ + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.nox +.cache +.pytest_cache +.tox + + +# Mac +.DS_Store + +# JetBrains +.idea + +# VS Code +.vscode + +# emacs +*~ + +# Built documentation +docs/_build +tests/testdata/*/docs/_build +bigquery/docs/generated +docs.metadata + +# Virtual environment +env/ + +# Test logs +coverage.xml +*sponge_log.xml + +# System test environment variables. +system_tests/local_test_setup + +# Make sure a generated file isn't accidentally committed. +pylintrc +pylintrc.test diff --git a/packages/gcp-sphinx-docfx-yaml/.librarian/state.yaml b/packages/gcp-sphinx-docfx-yaml/.librarian/state.yaml new file mode 100644 index 000000000000..601cece5b0cb --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/.librarian/state.yaml @@ -0,0 +1,10 @@ +image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:97c3041de740f26b132d3c5d43f0097f990e8b0d1f2e6707054840024c20ab0c +libraries: + - id: gcp-sphinx-docfx-yaml + version: 3.2.4 + apis: [] + source_roots: + - . + preserve_regex: [] + remove_regex: [] + tag_format: v{version} diff --git a/packages/gcp-sphinx-docfx-yaml/.pre-commit-config.yaml b/packages/gcp-sphinx-docfx-yaml/.pre-commit-config.yaml new file mode 100644 index 000000000000..1d74695f70b6 --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/.pre-commit-config.yaml @@ -0,0 +1,31 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml +- repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black +- repo: https://github.com/pycqa/flake8 + rev: 6.1.0 + hooks: + - id: flake8 diff --git a/packages/gcp-sphinx-docfx-yaml/.repo-metadata.json b/packages/gcp-sphinx-docfx-yaml/.repo-metadata.json new file mode 100644 index 000000000000..f9a6968e10ee --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/.repo-metadata.json @@ -0,0 +1,13 @@ +{ + "name": "gcp-sphinx-docfx-yaml", + "name_pretty": "Sphinx DocFX YAML Generator", + "product_documentation": "https://github.com/googleapis/sphinx-docfx-yaml", + "client_documentation": "https://github.com/googleapis/sphinx-docfx-yaml", + "issue_tracker": "https://github.com/googleapis/sphinx-docfx-yaml/issues", + "release_level": "preview", + "language": "python", + "repo": "googleapis/sphinx-docfx-yaml", + "distribution_name": "gcp-sphinx-docfx-yaml", + "codeowner_team": "@googleapis/dkp-team", + "library_type": "OTHER" +} diff --git a/packages/gcp-sphinx-docfx-yaml/CHANGELOG.md b/packages/gcp-sphinx-docfx-yaml/CHANGELOG.md new file mode 100644 index 000000000000..0dcdd5e12086 --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/CHANGELOG.md @@ -0,0 +1,409 @@ +# Changelog + +[PyPI History][1] + +[1]: https://pypi.org/project/gcp-sphinx-docfx-yaml/#history + +## [3.2.4](https://github.com/googleapis/sphinx-docfx-yaml/compare/v3.2.3...v3.2.4) (2025-10-22) + + +### Bug Fixes + +* Add support for formatting broken argspec entities ([#420](https://github.com/googleapis/sphinx-docfx-yaml/issues/420)) ([baf4389](https://github.com/googleapis/sphinx-docfx-yaml/commit/baf43897741666342cd2429f0894cecaa355702f)) + +## [3.2.3](https://github.com/googleapis/sphinx-docfx-yaml/compare/v3.2.2...v3.2.3) (2025-03-19) + + +### Bug Fixes + +* Update summary overview entry to deduplicate ([#413](https://github.com/googleapis/sphinx-docfx-yaml/issues/413)) ([0c714a8](https://github.com/googleapis/sphinx-docfx-yaml/commit/0c714a8390f9dc547d261cc8f6702428fa76ed5b)) + +## [3.2.2](https://github.com/googleapis/sphinx-docfx-yaml/compare/v3.2.1...v3.2.2) (2024-09-06) + + +### Bug Fixes + +* Ignore disambiguation for repeated entries ([#390](https://github.com/googleapis/sphinx-docfx-yaml/issues/390)) ([917c89b](https://github.com/googleapis/sphinx-docfx-yaml/commit/917c89bece5492dd8cbb09348d05af2a5fec82aa)) +* Retrieve keyword arguments for docstrings ([#389](https://github.com/googleapis/sphinx-docfx-yaml/issues/389)) ([bb6898e](https://github.com/googleapis/sphinx-docfx-yaml/commit/bb6898e054f6c53509f6394ba08eb44a36b8661b)) + +## [3.2.1](https://github.com/googleapis/sphinx-docfx-yaml/compare/v3.2.0...v3.2.1) (2024-05-07) + + +### Bug Fixes + +* Build Markdown relative to input directory ([#380](https://github.com/googleapis/sphinx-docfx-yaml/issues/380)) ([2a4b9fe](https://github.com/googleapis/sphinx-docfx-yaml/commit/2a4b9fe0b3ca94e27a9b1a6e5238711045b372c9)) +* Format enum data into table format ([#376](https://github.com/googleapis/sphinx-docfx-yaml/issues/376)) ([abc9667](https://github.com/googleapis/sphinx-docfx-yaml/commit/abc96675e1cbe3a9175bdf921142b32b16523f28)) + +## [3.2.0](https://github.com/googleapis/sphinx-docfx-yaml/compare/v3.1.0...v3.2.0) (2024-05-02) + + +### Features + +* Add support for enums ([#374](https://github.com/googleapis/sphinx-docfx-yaml/issues/374)) ([4575ffe](https://github.com/googleapis/sphinx-docfx-yaml/commit/4575ffebb8ded4b8ed43d4bfd3308deaa3a7b1b8)) + + +### Documentation + +* Add summary_overview template ([#367](https://github.com/googleapis/sphinx-docfx-yaml/issues/367)) ([39baecb](https://github.com/googleapis/sphinx-docfx-yaml/commit/39baecb0afcbd9a116cb809a0866bf61ac784f0e)) + +## [3.1.0](https://github.com/googleapis/sphinx-docfx-yaml/compare/v3.0.1...v3.1.0) (2024-04-01) + + +### Features + +* Add summary page for Classes and Modules ([#361](https://github.com/googleapis/sphinx-docfx-yaml/issues/361)) ([e56c3a7](https://github.com/googleapis/sphinx-docfx-yaml/commit/e56c3a732c2a71b76d0e44bd1ed889de4ffa1f63)) +* Add summary page support for methods and properties ([#363](https://github.com/googleapis/sphinx-docfx-yaml/issues/363)) ([e3ae026](https://github.com/googleapis/sphinx-docfx-yaml/commit/e3ae0262492f584516b10e1f8753b430e746ffa9)) +* Grab repository metadata ([#364](https://github.com/googleapis/sphinx-docfx-yaml/issues/364)) ([1318b24](https://github.com/googleapis/sphinx-docfx-yaml/commit/1318b2462c757368be3098824dd8924e4dc8b78f)) +* Support overview page ([#365](https://github.com/googleapis/sphinx-docfx-yaml/issues/365)) ([9985d13](https://github.com/googleapis/sphinx-docfx-yaml/commit/9985d134a45842eca9787483078101e0270e2345)) + +## [3.0.1](https://github.com/googleapis/sphinx-docfx-yaml/compare/v3.0.0...v3.0.1) (2024-03-13) + + +### Bug Fixes + +* Update dependencies to pin Sphinx for <5 compatibility ([#342](https://github.com/googleapis/sphinx-docfx-yaml/issues/342)) ([e60753a](https://github.com/googleapis/sphinx-docfx-yaml/commit/e60753a099bf8a603055e6441f6040dd042f228f)) + +## [3.0.0](https://github.com/googleapis/sphinx-docfx-yaml/compare/v2.0.7...v3.0.0) (2023-11-02) + + +### ⚠ BREAKING CHANGES + +* Bump minimum version to 3.10 ([#334](https://github.com/googleapis/sphinx-docfx-yaml/issues/334)) + +### Features + +* Bump minimum version to 3.10 ([#334](https://github.com/googleapis/sphinx-docfx-yaml/issues/334)) ([97c34cb](https://github.com/googleapis/sphinx-docfx-yaml/commit/97c34cbd2e2167e68224db1c3bc1775dddc9f6c3)) + +## [2.0.7](https://github.com/googleapis/sphinx-docfx-yaml/compare/v2.0.6...v2.0.7) (2023-11-01) + + +### Bug Fixes + +* Ignore cross reference conversion in examples ([#332](https://github.com/googleapis/sphinx-docfx-yaml/issues/332)) ([bbfa011](https://github.com/googleapis/sphinx-docfx-yaml/commit/bbfa01175d1b1cb4ccd670cbaa1ebfa511e61e8b)) + +## [2.0.6](https://github.com/googleapis/sphinx-docfx-yaml/compare/v2.0.5...v2.0.6) (2023-10-30) + + +### Bug Fixes + +* Refactor type hint retrieval ([#312](https://github.com/googleapis/sphinx-docfx-yaml/issues/312)) ([0c91f60](https://github.com/googleapis/sphinx-docfx-yaml/commit/0c91f60fb2eab8b184b1228d5f3eb133be7ae201)) +* Support docstrings without type added ([#311](https://github.com/googleapis/sphinx-docfx-yaml/issues/311)) ([d214d64](https://github.com/googleapis/sphinx-docfx-yaml/commit/d214d64c54d06fa715535b14932ac1ad67fa0d09)) +* Update annotation name extraction logic and add unit tests ([#320](https://github.com/googleapis/sphinx-docfx-yaml/issues/320)) ([220951d](https://github.com/googleapis/sphinx-docfx-yaml/commit/220951d341c27d345679f64fb67968320168e428)) + +## [2.0.5](https://github.com/googleapis/sphinx-docfx-yaml/compare/v2.0.4...v2.0.5) (2023-06-27) + + +### Bug Fixes + +* Pin markdown builder version ([#306](https://github.com/googleapis/sphinx-docfx-yaml/issues/306)) ([0d1879d](https://github.com/googleapis/sphinx-docfx-yaml/commit/0d1879df6446f70e088c8d5ac7df6a9a743a47c9)) + +## [2.0.4](https://github.com/googleapis/sphinx-docfx-yaml/compare/v2.0.3...v2.0.4) (2023-06-02) + + +### Bug Fixes + +* Allow top level page to only have index page ([#301](https://github.com/googleapis/sphinx-docfx-yaml/issues/301)) ([85c049a](https://github.com/googleapis/sphinx-docfx-yaml/commit/85c049a55f29ca78a1263e3f9ec4a3f5e4d5cad0)) + +## [2.0.3](https://github.com/googleapis/sphinx-docfx-yaml/compare/v2.0.2...v2.0.3) (2023-03-22) + + +### Bug Fixes + +* Add support for return annotation in syntax ([#291](https://github.com/googleapis/sphinx-docfx-yaml/issues/291)) ([16894ce](https://github.com/googleapis/sphinx-docfx-yaml/commit/16894ce1468ad96bdf3b216266f878fe45f75a12)) + +## [2.0.2](https://github.com/googleapis/sphinx-docfx-yaml/compare/v2.0.1...v2.0.2) (2023-02-03) + + +### Bug Fixes + +* Allow multiple/custom index pages to be used ([#280](https://github.com/googleapis/sphinx-docfx-yaml/issues/280)) ([7ee38d8](https://github.com/googleapis/sphinx-docfx-yaml/commit/7ee38d8335d974e51fd07623bdff323f99f50fad)) + +## [2.0.1](https://github.com/googleapis/sphinx-docfx-yaml/compare/v2.0.0...v2.0.1) (2023-01-30) + + +### Bug Fixes + +* Remove license headers in markdown files ([#273](https://github.com/googleapis/sphinx-docfx-yaml/issues/273)) ([a4c808f](https://github.com/googleapis/sphinx-docfx-yaml/commit/a4c808fdbfbf30bc536c7c22420229b0e40fa7c3)) + +## [2.0.0](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.6.0...v2.0.0) (2022-11-15) + + +### ⚠ BREAKING CHANGES + +* Retrieve all markdown pages (#266) + +### Features + +* Add golden testing ([#262](https://github.com/googleapis/sphinx-docfx-yaml/issues/262)) ([ff8902e](https://github.com/googleapis/sphinx-docfx-yaml/commit/ff8902ed5593b8cdb55e08809c24c49d0479200c)) +* Retrieve all markdown pages ([#266](https://github.com/googleapis/sphinx-docfx-yaml/issues/266)) ([1cee1ed](https://github.com/googleapis/sphinx-docfx-yaml/commit/1cee1edbcc8e7c441dedc0c6b9f80c545cac75a0)) + + +### Bug Fixes + +* Remove inheritance details ([#268](https://github.com/googleapis/sphinx-docfx-yaml/issues/268)) ([43751cf](https://github.com/googleapis/sphinx-docfx-yaml/commit/43751cf17818a9a6d4d2c9e37078f3356e0fb8a9)) +* Remove unused YAML fields to fix presubmit ([#265](https://github.com/googleapis/sphinx-docfx-yaml/issues/265)) ([10ecc44](https://github.com/googleapis/sphinx-docfx-yaml/commit/10ecc446d4f85801995f1810eca7261a851643a5)) + +## [1.6.0](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.5.0...v1.6.0) (2022-10-13) + + +### Features + +* Use GitHub's default README as index page ([#255](https://github.com/googleapis/sphinx-docfx-yaml/issues/255)) ([17f6ca0](https://github.com/googleapis/sphinx-docfx-yaml/commit/17f6ca0ef8fe6aeed096a5356cac8944f8884b82)) + + +### Bug Fixes + +* Render emphasis properly and markdown in tables ([#258](https://github.com/googleapis/sphinx-docfx-yaml/issues/258)) ([4bbd921](https://github.com/googleapis/sphinx-docfx-yaml/commit/4bbd921f116cccd86d30597a254087f25f074728)) + +## [1.5.0](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.4.8...v1.5.0) (2022-07-11) + + +### Features + +* support devsite notices ([#222](https://github.com/googleapis/sphinx-docfx-yaml/issues/222)) ([0da9224](https://github.com/googleapis/sphinx-docfx-yaml/commit/0da9224712f846485bdcc13807904b7e5e094e34)) + + +### Bug Fixes + +* include dependency for librarytest ([#218](https://github.com/googleapis/sphinx-docfx-yaml/issues/218)) ([420780b](https://github.com/googleapis/sphinx-docfx-yaml/commit/420780bf873bd0fc993fbbaa98833649bf0b2762)) + +### [1.4.8](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.4.7...v1.4.8) (2022-05-24) + + +### Bug Fixes + +* add hardcoded IAM references temporarily ([#209](https://github.com/googleapis/sphinx-docfx-yaml/issues/209)) ([5dc99d2](https://github.com/googleapis/sphinx-docfx-yaml/commit/5dc99d25532e668d5bf5fc1402b93ed5f189655e)) + +### [1.4.7](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.4.6...v1.4.7) (2022-04-12) + + +### Bug Fixes + +* add markdown header if it is missing ([#203](https://github.com/googleapis/sphinx-docfx-yaml/issues/203)) ([ccd53bd](https://github.com/googleapis/sphinx-docfx-yaml/commit/ccd53bdba8cdfe08d900a7b05f235e635a2f0441)) + +### [1.4.6](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.4.5...v1.4.6) (2022-04-06) + + +### Bug Fixes + +* support parsing summary docstring that is not well formed ([#200](https://github.com/googleapis/sphinx-docfx-yaml/issues/200)) ([a1b362d](https://github.com/googleapis/sphinx-docfx-yaml/commit/a1b362d611be6a60d19e2b5b06806554eea111f5)) + +### [1.4.5](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.4.4...v1.4.5) (2022-03-18) + + +### Bug Fixes + +* format code snippets properly ([#193](https://github.com/googleapis/sphinx-docfx-yaml/issues/193)) ([ef7a337](https://github.com/googleapis/sphinx-docfx-yaml/commit/ef7a3370756ba20cc78ad8193abfaaf5cd268f0c)) + +### [1.4.4](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.4.3...v1.4.4) (2022-03-03) + + +### Bug Fixes + +* parse docstring that come without summaries ([#187](https://github.com/googleapis/sphinx-docfx-yaml/issues/187)) ([8282604](https://github.com/googleapis/sphinx-docfx-yaml/commit/8282604105893a8834cbee09cd9e0080340f31de)) + +### [1.4.3](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.4.2...v1.4.3) (2022-02-15) + + +### Bug Fixes + +* retrieve constructors ([#181](https://github.com/googleapis/sphinx-docfx-yaml/issues/181)) ([1e6efa4](https://github.com/googleapis/sphinx-docfx-yaml/commit/1e6efa4007e3191ad07dd4e82fcb06a8fd1be746)) +* use `id` field for Attributes instead of `name` ([#179](https://github.com/googleapis/sphinx-docfx-yaml/issues/179)) ([fa38c8c](https://github.com/googleapis/sphinx-docfx-yaml/commit/fa38c8ce98b92a460755c8db548cfee9309812c7)) + +### [1.4.2](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.4.1...v1.4.2) (2022-02-07) + + +### Bug Fixes + +* update markdown header parser ([#177](https://github.com/googleapis/sphinx-docfx-yaml/issues/177)) ([71d50cc](https://github.com/googleapis/sphinx-docfx-yaml/commit/71d50cce1979a8673499f731411798bfb15c7ba6)) + +### [1.4.1](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.4.0...v1.4.1) (2022-01-28) + + +### Bug Fixes + +* enable upgrading docs ([#172](https://github.com/googleapis/sphinx-docfx-yaml/issues/172)) ([bb68ea9](https://github.com/googleapis/sphinx-docfx-yaml/commit/bb68ea95ded306ccb3513c9684ce2d1ad6b3e74c)) + +## [1.4.0](https://github.com/googleapis/sphinx-docfx-yaml/compare/v1.3.3...v1.4.0) (2022-01-28) + + +### Features + +* add syntax highlighting support for Markdown pages ([#170](https://github.com/googleapis/sphinx-docfx-yaml/issues/170)) ([9898807](https://github.com/googleapis/sphinx-docfx-yaml/commit/98988072c3a32ff1d1be44cb835eea0ad787e8e9)) + +### [1.3.3](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v1.3.2...v1.3.3) (2021-11-29) + + +### Bug Fixes + +* expand entry names in Overview page to be more descriptive ([#159](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/159)) ([7bd6416](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/7bd64160cda8a84cdbd14f61bd39d5594b048bd2)) + +### [1.3.2](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v1.3.1...v1.3.2) (2021-11-16) + + +### Bug Fixes + +* gracefully handle format_code exceptions ([#152](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/152)) ([a679ace](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/a679ace42c88ac40d7336f6d8b6266191932a3ea)) + +### [1.3.1](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v1.3.0...v1.3.1) (2021-11-15) + + +### Bug Fixes + +* resolve square bracketed references ([#146](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/146)) ([fa049ac](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/fa049ace9d14e1f9993313983ad3426ff041672d)) + +## [1.3.0](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v1.2.0...v1.3.0) (2021-11-15) + + +### Features + +* format signature using black ([#144](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/144)) ([4462b93](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/4462b93a732c9aedf35ad3321269bd4cea9f26dc)) + +## [1.2.0](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v1.1.2...v1.2.0) (2021-10-05) + + +### Features + +* find more items to cross reference ([#138](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/138)) ([a0f82dd](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/a0f82ddc45d8c09ecae6ab55d6366ab6e666397b)) + +### [1.1.2](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v1.1.1...v1.1.2) (2021-09-14) + + +### Bug Fixes + +* disambiguate after grouping by packages and versions ([#132](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/132)) ([53d68fe](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/53d68fe2a05302e4dc955157d9e08b9de33ec947)) + +### [1.1.1](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v1.1.0...v1.1.1) (2021-08-30) + + +### Bug Fixes + +* make plugin more verbose ([#123](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/123)) ([1f25757](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/1f2575730935f0be2795c37262aa1e465221daa7)) + +## [1.1.0](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v1.0.1...v1.1.0) (2021-08-26) + + +### Features + +* handle additional docstring items ([#116](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/116)) ([8c31924](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/8c319244d726c3425fcb9d10ee0a3f4157193e75)) + +### [1.0.1](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v1.0.0...v1.0.1) (2021-08-25) + + +### Bug Fixes + +* do not omit arguments retrieved from docstring ([#114](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/114)) ([18bf0de](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/18bf0de2b761feabdcba071690d04b4dac0a6001)) +* parse markdown header more carefully ([#111](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/111)) ([485b248](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/485b248091a6dffd8f4c0cd77a8fcb4fde8eca09)) + +## [1.0.0](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v0.5.2...v1.0.0) (2021-08-24) + + +### ⚠ BREAKING CHANGES + +* add markdown page support (#102) + +### Features + +* add markdown page support ([#102](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/102)) ([878f1c3](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/878f1c33f3d1ff59df3417ddffd1ac3cecd3f8c1)) +* group left-nav entries into versions and groups ([#96](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/96)) ([ee89394](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/ee8939425682bb81294214dd23b6aaeff74c36da)) + + +### Bug Fixes + +* recover lost function arguments and argument types ([#93](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/93)) ([b90dd0f](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/b90dd0f7a1e8e00630f24945b5425e20511be7c5)) +* retrieve file name as much as possible ([#100](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/100)) ([34cad2b](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/34cad2b2159ee73a5d1d1c16a504a1f82527deda)) +* use file name instead of object name for TOC ([#97](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/97)) ([48279ef](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/48279ef23e4962cab7a5b05cf2e1dc6d0b8907f3)) +* use the uid for toc entries ([#104](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/104)) ([1364dfc](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/1364dfce95044bd4e3763f40af5d281fa2ddb96a)) + +### [0.5.2](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v0.5.1...v0.5.2) (2021-07-30) + + +### Bug Fixes + +* parse xrefs differently with new xref format ([#90](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/90)) ([22485e8](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/22485e82b1e4c3be2f7589434d53c75b28921266)) + +### [0.5.1](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v0.5.0...v0.5.1) (2021-07-29) + + +### Bug Fixes + +* handle more xrefs and keep long uid ([#85](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/85)) ([fd4f9f3](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/fd4f9f373fcf6429d0faa76846d2d50673809a59)) +* remove redundant class info for subclasses ([#87](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/87)) ([06bb556](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/06bb556a4c2371ef05e9749c6f68b9eeb18315a6)) + +## [0.5.0](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v0.4.0...v0.5.0) (2021-07-28) + + +### Features + +* add subclasses to children and reference ([#77](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/77)) ([0cab5f6](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/0cab5f6cd6cd9b1da2f5f63cbcabeea69e0d7c81)) +* add subPackage types for better classification ([#76](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/76)) ([3c84f3e](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/3c84f3ea05677e2e8a5a6659a14f281f537ae37a)) +* process xrefs properly ([#78](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/78)) ([fcc1989](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/fcc1989a114640fd21955d35ef3eabce2d043fc9)) + +## [0.4.0](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v0.3.4...v0.4.0) (2021-07-21) + + +### Features + +* add short snippet for missing summary ([#73](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/73)) ([bb432e7](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/bb432e7ef0e1df6b4315306ddb3b8a82eebb375f)) + + +### Bug Fixes + +* disambiguate all entry names to clarify duplicate names ([#72](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/72)) ([b632eb7](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/b632eb74fd3ce1dd16bc626b9a23ff79c2b6559f)) + +### [0.3.4](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v0.3.3...v0.3.4) (2021-07-05) + + +### Bug Fixes + +* deduplicate entries in children and references ([#61](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/61)) ([6d5407b](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/6d5407b6c004587071d2523f1bad4717678774da)) + +### [0.3.3](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v0.3.2...v0.3.3) (2021-06-25) + + +### Bug Fixes + +* handle entries that cannot be disambiguated ([#59](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/59)) ([7678b24](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/7678b246636bf8387e7049af11bce1a33a9a5826)) + +### [0.3.2](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v0.3.1...v0.3.2) (2021-06-24) + + +### Bug Fixes + +* properly handle Raises section for GoogleDocstring ([#56](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/56)) ([793dd48](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/793dd4847cfbc6bc060d7a8840bd102f4bf37058)) +* update parser to correctly parse desired tokens ([#55](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/55)) ([d1e18c7](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/d1e18c7cb64aac9710ff18863e7c78306e93d568)) + +### [0.3.1](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v0.3.0...v0.3.1) (2021-06-21) + + +### Bug Fixes + +* update dependency requirements ([#48](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/48)) ([c1c036f](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/c1c036fd00be08f219ffa4ebdfb5d13e2ee5768a)) + +## [0.3.0](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v0.2.0...v0.3.0) (2021-06-21) + + +### Features + +* Add support for Property and missing content ([#41](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/41)) ([5ac499f](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/5ac499fae23983cf929459ccc9a2ea9dcebae790)) +* shorten function names shown on pages ([#22](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/22)) ([13edc85](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/13edc859bea7c6150d6b688ddd3d65cef1ad33d7)) + + +### Bug Fixes + +* complete toc disambiguation ([#45](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/45)) ([8928614](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/892861441853735b4ab608aab94edd824ae77137)) +* remove function and method name override ([#42](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/42)) ([ab8f265](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/ab8f2656682ea4727c68f3bb5205260e16fb8f5c)) + +## [0.2.0](https://www.github.com/googleapis/sphinx-docfx-yaml/compare/v0.1.0...v0.2.0) (2021-05-13) + + +### Features + +* clarify names in the left nav ([#16](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/16)) ([14cac76](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/14cac765681b5cebca4361adbdf7010a7728c227)) + +## 0.1.0 (2021-03-25) + + +### Documentation + +* keep Python COC, update README ([#6](https://www.github.com/googleapis/sphinx-docfx-yaml/issues/6)) ([3a60b1a](https://www.github.com/googleapis/sphinx-docfx-yaml/commit/3a60b1af9c2c39fe1bb974fb899f87c81efc0274)) diff --git a/packages/gcp-sphinx-docfx-yaml/CODE_OF_CONDUCT.md b/packages/gcp-sphinx-docfx-yaml/CODE_OF_CONDUCT.md new file mode 100644 index 000000000000..039f43681204 --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/CODE_OF_CONDUCT.md @@ -0,0 +1,95 @@ + +# Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + + +Reports should be directed to *googleapis-stewards@google.com*, the +Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out to the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/packages/gcp-sphinx-docfx-yaml/CONTRIBUTING.md b/packages/gcp-sphinx-docfx-yaml/CONTRIBUTING.md new file mode 100644 index 000000000000..1237ad35d3f8 --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/CONTRIBUTING.md @@ -0,0 +1,34 @@ +**Please note that this is the forked version of the original repository, which +is found on https://github.com/docascode/sphinx-docfx-yaml. Unless the issue +applies only to this repository, please also file an issue and/or contribute +to the original repository as well.** + +# How to Contribute + +We'd love to accept your patches and contributions to this project. +There are just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement (CLA). You (or your employer) retain the copyright to your +contribution; this simply gives us permission to use and redistribute your +contributions as part of the project. Head over to + to see your current agreements on file or +to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code Reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + +## Community Guidelines + +This project follows +[Google's Open Source Community Guidelines](https://opensource.google/conduct/). diff --git a/packages/gcp-sphinx-docfx-yaml/LICENSE b/packages/gcp-sphinx-docfx-yaml/LICENSE new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/gcp-sphinx-docfx-yaml/README.rst b/packages/gcp-sphinx-docfx-yaml/README.rst new file mode 100644 index 000000000000..736966df9c61 --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/README.rst @@ -0,0 +1,101 @@ +This is not an officially supported Google product. + +This is a forked version of the original from https://github.com/docascode/sphinx-docfx-yaml. + +Feel free to use this forked repository for personal or experimental use, use the original otherwise. + +Sphinx DocFX YAML +================= + +Sphinx DocFX YAML is an exporter for the Sphinx Autodoc module into `DocFX YAML `_. + +You can read the full documentation online at http://sphinx-docfx-yaml.readthedocs.io + +Contents +-------- + +.. toctree:: + :glob: + :maxdepth: 2 + + design + layout + api + +Basic Workflow +-------------- + +* Write RST that includes Python `autodoc `_ +* Render internal doctree into YAML +* Output YAML into output directory + +Install +------- + +To use this forked version, install GCP docfx-yaml: + +.. code:: bash + + pip install gcp-sphinx-docfx-yaml + +Then add it to your Sphinx project's ``conf.py``: + +.. code:: python + + # Order matters here. + # The extension must be defined *after* autodoc, + # because it uses a signal that autodoc defines + extensions = ['sphinx.ext.autodoc', 'docfx_yaml.extension'] + +Make sure you are using autodoc in your code somewhere:: + + .. automodule:: foo.bar + +Then build your documentation:: + + make html + +Inside your build directory (``_build/html`` usually), +the ``docfx_yaml`` will contain the YAML files that are output. + +Testing +------- + +To run the tests in this repository, run: + +.. code:: bash + + pip install tox + tox -e docs + +from the top directory of this repository. + +.. Modes + ----- + + There are two output modes that specify the structure of the YAML files. + The first is ``module`` which means that the YAML files will be output in files corresponding to the name of their module. + The second modes is ``rst`` which outputs them in the same structure as the RST files they were defined in. + +Design +------ + +Read more about the design in our :doc:`design`. + +Layout +------ + +This project has a few different pieces at this point. +It's primary goal was to integrate the Azure Python SDK into the docfx tooling. +You can read more about the pieces currently set up in the :doc:`layout`. + + +Napoleon Support +---------------- + +We support ``sphinx.ext.napoleon`` for parsing docstrings in other formats. +Currently all markup that maps to existing Sphinx `info field lists `_ will work, +along with ``Examples``. +In order to pull examples out, +you need the ``napoleon_use_admonition_for_examples`` set to ``True``. + diff --git a/packages/gcp-sphinx-docfx-yaml/SECURITY.md b/packages/gcp-sphinx-docfx-yaml/SECURITY.md new file mode 100644 index 000000000000..8b58ae9c01ae --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/SECURITY.md @@ -0,0 +1,7 @@ +# Security Policy + +To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). + +The Google Security Team will respond within 5 working days of your report on g.co/vulnz. + +We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. diff --git a/packages/gcp-sphinx-docfx-yaml/docfx_yaml/__init__.py b/packages/gcp-sphinx-docfx-yaml/docfx_yaml/__init__.py new file mode 100644 index 000000000000..690df65fb6bc --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/docfx_yaml/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/packages/gcp-sphinx-docfx-yaml/docfx_yaml/directives.py b/packages/gcp-sphinx-docfx-yaml/docfx_yaml/directives.py new file mode 100644 index 000000000000..f870d23e853a --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/docfx_yaml/directives.py @@ -0,0 +1,42 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# coding: utf-8 + +""" +This module is used to add extra supported directives to sphinx. +""" + +from docutils.parsers.rst.directives.admonitions import BaseAdmonition +from docutils.parsers.rst import Directive +from docutils import nodes + +from .nodes import remarks + + +class RemarksDirective(BaseAdmonition): + """A directive to handle 'remarks' blocks.""" + node_class = remarks + +class TodoDirective(Directive): + """A directive to ignore 'todo' blocks.""" + + # Enable content in the directive + has_content = True + + def run(self) -> list[nodes.Node]: + """This directive is ignored, so return empty list.""" + return_nodes = [] + + return return_nodes diff --git a/packages/gcp-sphinx-docfx-yaml/docfx_yaml/extension.py b/packages/gcp-sphinx-docfx-yaml/docfx_yaml/extension.py new file mode 100644 index 000000000000..4cdfd8da4413 --- /dev/null +++ b/packages/gcp-sphinx-docfx-yaml/docfx_yaml/extension.py @@ -0,0 +1,2565 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# -*- coding: utf-8 -*- +""" +Sphinx DocFX YAML Top-level Extension. + +This extension allows you to automagically generate DocFX YAML from your Python AutoAPI docs. +""" + +import ast +from collections import defaultdict +from collections.abc import Mapping, MutableSet, Sequence +import copy +from functools import partial +import inspect +from itertools import zip_longest +import json +import logging +import os +from pathlib import Path +import re +import shutil +from typing import Any, Iterable +import black +from black import InvalidInput + +try: + from subprocess import getoutput +except ImportError: + from commands import getoutput + +from yaml import safe_dump as dump + +import sphinx.application +from sphinx.util.console import darkgreen, bold +from sphinx.util import ensuredir +from sphinx.errors import ExtensionError +from sphinx.util.nodes import make_refnode +from sphinx.ext.napoleon import GoogleDocstring +from sphinx.ext.napoleon import Config +from sphinx.ext.napoleon import _process_docstring + +from .utils import transform_node, transform_string +from .settings import API_ROOT +from .monkeypatch import patch_docfields +from .directives import RemarksDirective, TodoDirective +from .nodes import remarks +from docfx_yaml import markdown_utils + +import subprocess +import ast +from docuploader import shell + +class Bcolors: + HEADER = '\033[95m' + OKBLUE = '\033[94m' + OKGREEN = '\033[92m' + WARNING = '\033[93m' + FAIL = '\033[91m' + ENDC = '\033[0m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' + + +try: + from conf import * +except ImportError: + print(Bcolors.FAIL + 'can not import conf.py! ' + 'you should have a conf.py in working project folder' + Bcolors.ENDC) + +METHOD = 'method' +FUNCTION = 'function' +MODULE = 'module' +CLASS = 'class' +EXCEPTION = 'exception' +ATTRIBUTE = 'attribute' +REFMETHOD = 'meth' +REFFUNCTION = 'func' +INITPY = '__init__.py' +# Regex expression for checking references of pattern like ":class:`~package_v1.module`" +REF_PATTERN = r':(py:)?(func|class|meth|mod|ref|attr|exc):`~?[a-zA-Z0-9_.<> ]*(\(\))?`' +# Regex expression for checking references of pattern like "~package_v1.subpackage.module" +REF_PATTERN_LAST = r'~([a-zA-Z0-9_<>]*\.)*[a-zA-Z0-9_<>]*(\(\))?' +# Regex expression for checking references of pattern like +# "[module][google.cloud.cloudkms_v1.module]" +REF_PATTERN_BRACKETS = r'\[[a-zA-Z0-9_<>\-. ]+\]\[[a-zA-Z0-9_<>\-. ]+\]' + +REF_PATTERNS = [ + REF_PATTERN, + REF_PATTERN_LAST, + REF_PATTERN_BRACKETS, +] + +PROPERTY = 'property' +CODEBLOCK = "code-block" +CODE = "code" +PACKAGE = "package" + +# DevSite specific notices that can be used. +NOTE = 'note' +CAUTION = 'caution' +WARNING = 'warning' +IMPORTANT = 'special' +KEYPOINT = 'key-point' +KEYTERM = 'key-term' +OBJECTIVE = 'objective' +SUCCESS = 'success' +BETA = 'beta' +PREVIEW = 'preview' +DEPRECATED = 'deprecated' + +NOTICES = { + NOTE: 'Note', + CAUTION: 'Caution', + WARNING: 'Warning', + IMPORTANT: 'Important', + KEYPOINT: 'Key Point', + KEYTERM: 'Key Term', + OBJECTIVE: 'Objective', + SUCCESS: 'Success', + BETA: 'Beta', + PREVIEW: 'Preview', + DEPRECATED: 'deprecated', +} + +_SUMMARY_TYPE_BY_ITEM_TYPE = { + # Modules and Classes are similar types. + MODULE: CLASS, + CLASS: CLASS, + # Methods and Functions are similar types. + METHOD: METHOD, + FUNCTION: METHOD, + # Properties and Attributes are similar types. + PROPERTY: PROPERTY, + ATTRIBUTE: PROPERTY, +} +# Construct a mapping of name and content for each unique summary type entry. +_ENTRY_NAME_AND_ENTRY_CONTENT_BY_SUMMARY_TYPE = { + summary_type: [[], []] # entry name then entry content + for summary_type in set(_SUMMARY_TYPE_BY_ITEM_TYPE.values()) +} +# Mapping for each summary page entry's file name and entry name. +_FILE_NAME_AND_ENTRY_NAME_BY_SUMMARY_TYPE = { + CLASS: ('summary_class.yml', "Classes"), + METHOD: ('summary_method.yml', "Methods"), + PROPERTY: ('summary_property.yml', "Properties and Attributes"), +} + +# Disable blib2to3 output that clutters debugging log. +logging.getLogger("blib2to3").setLevel(logging.ERROR) + + +# Type alias used for yaml entries. +_yaml_type_alias = dict[str, Any] + + +def _grab_repo_metadata() -> Mapping[str, str] | None: + """Retrieves the repository's metadata info if found. + + Returns: + dict[str, str] | None: The repository's metadata info if found, + otherwise None. + """ + try: + with open('.repo-metadata.json', 'r') as metadata_file: + json_content = json.load(metadata_file) + # Return outside of context manager for safe close + return json_content + except Exception: + return None + + +def build_init(app: sphinx.application.Sphinx) -> None: + """Initializes the build. + + Args: + app (sphinx.application.Sphinx): The sphinx application. + """ + print("Retrieving repository metadata.") + if not (repo_metadata := _grab_repo_metadata()): + print("Failed to retrieve repository metadata.") + app.env.library_shortname = "" + else: + print("Successfully retrieved repository metadata.") + app.env.library_shortname = repo_metadata["name"] + print("Running sphinx-build with Markdown first...") + markdown_utils.run_sphinx_markdown(app) + print("Completed running sphinx-build with Markdown files.") + + """ + Set up environment data + """ + if not app.config.docfx_yaml_output: + raise ExtensionError('You must configure an docfx_yaml_output setting') + + # This stores YAML object for modules + app.env.docfx_yaml_modules = {} + # This stores YAML object for classes + app.env.docfx_yaml_classes = {} + # This stores YAML object for functions + app.env.docfx_yaml_functions = {} + # This store the data extracted from the info fields + app.env.docfx_info_field_data = {} + # This stores signature for functions and methods + app.env.docfx_signature_funcs_methods = {} + # This store the uid-type mapping info + app.env.docfx_info_uid_types = {} + # This stores uidnames of docstrings already parsed + app.env.docfx_uid_names = {} + # This stores file path for class when inspect cannot retrieve file path + app.env.docfx_class_paths = {} + # This stores the name and href of the nested markdown pages. + app.env.markdown_pages = defaultdict(list) + # This stores all the markdown pages moved from the plugin, will be used + # to compare and delete unused pages. + app.env.moved_markdown_pages = set() + + app.env.docfx_xrefs = {} + + remote = getoutput('git remote -v') + + try: + app.env.docfx_remote = remote.split('\t')[1].split(' ')[0] + except Exception: + app.env.docfx_remote = None + try: + app.env.docfx_branch = getoutput('git rev-parse --abbrev-ref HEAD').strip() + except Exception: + app.env.docfx_branch = None + + try: + app.env.docfx_root = getoutput('git rev-parse --show-toplevel').strip() + except Exception: + app.env.docfx_root = None + + patch_docfields(app) + + app.docfx_transform_node = partial(transform_node, app) + app.docfx_transform_string = partial(transform_string, app) + + +def _get_cls_module(_type: str, name: str) -> tuple[str | None, str | None]: + """Gets the class and module name for an object. + + Args: + _type (str): The type of the object. + name (str): The name of the object. + + Returns: + tuple: A tuple containing the class and module name. + """ + + cls = None + if _type in [FUNCTION, EXCEPTION]: + module = '.'.join(name.split('.')[:-1]) + elif _type in [METHOD, ATTRIBUTE, PROPERTY]: + cls = '.'.join(name.split('.')[:-1]) + module = '.'.join(name.split('.')[:-2]) + elif _type in [CLASS]: + cls = name + module = '.'.join(name.split('.')[:-1]) + elif _type in [MODULE]: + module = name + else: + return (None, None) + return (cls, module) + + +def _create_reference(datam: dict, parent: str, is_external: bool = False) -> dict: + """Creates a reference to another object. + + Args: + datam (dict): The data of the object to reference. + parent (str): The parent of the object. + is_external (bool): Whether the reference is external. + + Returns: + dict: A dictionary representing the reference. + """ + return { + 'uid': datam['uid'], + 'parent': parent, + 'isExternal': is_external, + 'name': datam['source']['id'], + 'fullName': datam['fullName'], + } + + +def _refact_example_in_module_summary(lines: list[str]) -> list[str]: + """Refactors the example in the module summary. + + Args: + lines (list): A list of strings representing the lines of the summary. + + Returns: + list: A list of strings representing the refactored lines. + """ + new_lines = [] + block_lines = [] + example_block_flag = False + for line in lines: + if line.startswith('.. admonition:: Example'): + example_block_flag = True + line = '### Example\n\n' + new_lines.append(line) + elif example_block_flag and len(line) != 0 and not line.startswith(' '): + example_block_flag = False + new_lines.append(''.join(block_lines)) + new_lines.append(line) + block_lines[:] = [] + elif example_block_flag: + if line == ' ': # origianl line is blank line ('\n'). + line = '\n' # after outer ['\n'.join] operation, + # this '\n' will be appended to previous line then. BINGO! + elif line.startswith(' '): + # will be indented by 4 spaces according to yml block syntax. + # https://learnxinyminutes.com/docs/yaml/ + line = ' ' + line + '\n' + block_lines.append(line) + + else: + new_lines.append(line) + return new_lines + + +def _resolve_reference_in_module_summary( + pattern: str, + lines: list[str], +) -> tuple[list[str], list[str]]: + """Resolves references in the module summary. + + Args: + pattern (str): The regex pattern to use for matching references. + lines (list): A list of strings representing the lines of the summary. + + Returns: + tuple: A tuple containing the resolved lines and a list of xrefs. + """ + new_lines, xrefs = [], [] + for line in lines: + matched_objs = list(re.finditer(pattern, line)) + new_line = line + for matched_obj in matched_objs: + start = matched_obj.start() + end = matched_obj.end() + matched_str = line[start:end] + # TODO: separate this portion into a function per pattern. + if pattern == REF_PATTERN: + if '<' in matched_str and '>' in matched_str: + # match string like ':func:`***<***>`' + index = matched_str.index('<') + ref_name = matched_str[index+1:-2] + else: + # match string like ':func:`~***`' or ':func:`***`' + index = matched_str.index('~') if '~' in matched_str else matched_str.index('`') + ref_name = matched_str[index+1:-1] + + index = ref_name.rfind('.') + 1 + # Find the last component of the target. "~Queue.get" only returns + ref_name = ref_name[index:] + + elif pattern == REF_PATTERN_LAST: + index = matched_str.rfind('.') + 1 + if index == 0: + # If there is no dot, push index to not include tilde + index = 1 + ref_name = matched_str[index:] + + elif pattern == REF_PATTERN_BRACKETS: + lbracket = matched_str.find('[')+1 + rbracket = matched_str.find(']') + ref_name = matched_str[lbracket:rbracket] + + else: + raise ValueError(f'Encountered wrong ref pattern: \n{pattern}') + + # Find the uid to add for xref + index = matched_str.find("google.cloud") + if index > -1: + xref = matched_str[index:] + while not xref[-1].isalnum(): + xref = xref[:-1] + xrefs.append(xref) + + # Check to see if we should create an xref for it. + if 'google.cloud' in matched_str: + new_line = new_line.replace(matched_str, f'{ref_name}') + # If it not a Cloud library, don't create xref for it. + else: + # Carefully extract the original uid + if pattern == REF_PATTERN: + index = matched_str.index('~') if '~' in matched_str else matched_str.index('`') + ref_name = matched_str[index+1:-1] + else: + ref_name = matched_str[1:] + new_line = new_line.replace(matched_str, f'`{ref_name}`') + + new_lines.append(new_line) + return new_lines, xrefs + + +def extract_keyword(line: str) -> str: + """Extracts the keyword from a line. + + Args: + line (str): The line to extract the keyword from. + + Returns: + str: The extracted keyword. + """ + # Must be in the form of: + # .. keyword:: + # where it begind with 2 dot prefix, followed by a space, then the keyword + # followed by 2 collon suffix. + try: + return line[ 3 : line.index("::") ] + except ValueError: + # TODO: handle reST template. + if line[3] != "_": + raise ValueError(f"Wrong formatting enoucntered for \n{line}") + return line + + +def indent_code_left(lines: str, tab_space: int) -> str: + """Indents code lines left by tab_space. + + Args: + lines: String lines of code. + tab_space: Number of spaces to indent to left by. + + Returns: + String lines of left-indented code. + """ + parts = lines.split("\n") + parts = [part[tab_space:] for part in parts] + return "\n".join(parts) + + +def _parse_enum_content(parts: Sequence[str]) -> Sequence[Mapping[str, str]]: + """Parses the given content for enums. + + Args: + parts: The content to parse, given in the form of a sequence of str, + which have been split by newlines and are left-indented. + + Returns: + Sequence of mapping of enum entries for name and description. + + Raises: + ValueError: If the `Values` enum docstring is malformed. + """ + enum_content: MutableSequence[Mapping[str, str]] = [] + enum_name = "" + enum_description = [] + for part in parts: + if ( + (current_tab_space := len(part) - len(part.lstrip(" "))) > 0 + ): + enum_description.append(indent_code_left(part, current_tab_space)) + continue + + # Add the new enum and start collecting new entry. + if enum_name and enum_description: + enum_content.append({ + "id": enum_name, + "description": " ".join(enum_description), + }) + + enum_description = [] + # Only collect the name, not the value. + enum_name = part.split(" ")[0] + + if not enum_name and not enum_description: + raise ValueError( + "The enum docstring is not formatted well. Check the" + " docstring:\n\n{}".format("\n".join(parts)) + ) + + # Add the last entry. + if not enum_name or not enum_description: + raise ValueError( + "The enum docstring is not formatted well. Check the" + " docstring:\n\n{}".format("\n".join(parts)) + ) + + enum_content.append({ + "id": enum_name, + "description": " ".join(enum_description), + }) + + return enum_content + + +def _parse_docstring_summary( + summary: str, +) -> tuple[str, Mapping[str, str], Mapping[str, str]]: + """ + Parses the docstring tokens found in the summary. + + Looks for tokens such as codeblocks, attributes, notices and enums. + + Args: + summary: The content to parse docstring for. + + Returns: + A tuple of the following: + * str: The content with parsed docstrings. + * Mapping[str, str]: Attribute entries if found. + * Mapping[str, str]: Enum entries if found. + """ + summary_parts = [] + attributes = [] + attribute_type_token = ":type:" + enum_type_token = "Values:" + enums = [] + keyword = name = description = var_type = "" + + notice_open_tag = '' + + # We need to separate in chunks, which is defined by 3 newline breaks. + # Otherwise when parsing for code and blocks of stuff, we will not be able + # to have the entire context when just splitting by single newlines. + # We should fix this from the library side for consistent docstring style, + # rather than monkey-patching it in the plugin. + for part in summary.split("\n\n\n"): + # Don't process empty string + if part == "": + continue + + # Continue adding parts for code-block. + if keyword and keyword in [CODE, CODEBLOCK]: + # If we reach the end of keyword, close up the code block. + if not part.startswith(" "*tab_space) or part.startswith(".."): + if code_snippet: + parts = [indent_code_left(part, tab_space) for part in code_snippet] + summary_parts.append("\n\n".join(parts)) + summary_parts.append("```\n") + keyword = "" + + else: + if tab_space == -1: + parts = [split_part for split_part in part.split("\n") if split_part] + tab_space = len(parts[0]) - len(parts[0].lstrip(" ")) + if tab_space == 0: + raise ValueError(f"Code in the code block should be indented. Please check the docstring: \n{summary}") + if not part.startswith(" "*tab_space): + # No longer looking at code-block, reset keyword. + if code_snippet: + parts = [indent_code_left(part, tab_space) for part in code_snippet] + summary_parts.append("\n\n".join(parts)) + keyword = "" + summary_parts.append("```\n") + code_snippet.append(part) + continue + + # Attributes come in 3 parts, parse the latter two here. + elif keyword and keyword == ATTRIBUTE: + # Second part, extract the description. + if not found_name: + description = part.strip() + found_name = True + continue + # Third part, extract the attribute type then add the completed one + # set to a list to be returned. Close up as needed. + else: + if attribute_type_token in part: + var_type = part.split(":type:")[1].strip() + keyword = "" + if name and description and var_type: + attributes.append({ + "id": name, + "description": description, + "var_type": var_type + }) + + else: + print(f"Could not process the attribute. Please check the docstring: \n{summary}") + + continue + + elif keyword and keyword in NOTICES: + # Determine how much code block is indented to format properly. + if tab_space == -1: + parts = [split_part for split_part in part.split("\n") if split_part] + tab_space = len(parts[0]) - len(parts[0].lstrip(" ")) + if tab_space == 0: + raise ValueError("Content in the block should be indented."\ + f"Please check the docstring: \n{summary}") + if not part.startswith(" "*tab_space): + if notice_body: + parts = [indent_code_left(part, tab_space) for part in notice_body] + summary_parts.append("\n".join(parts)) + + summary_parts.append(notice_close_tag) + keyword = "" + notice_body.append(part) + continue + + # Parse keywords if found. + # lstrip is added to parse code blocks that are not formatted well. + if (potential_keyword := part.lstrip('\n')) and ( + potential_keyword.startswith('..') or + potential_keyword.startswith(enum_type_token) + ): + if enum_type_token in potential_keyword: + # Handle the enum section starting with `Values:` + parts = [split_part for split_part in part.split("\n") if split_part][1:] + if not parts: + continue + tab_space = len(parts[0]) - len(parts[0].lstrip(" ")) + if tab_space == 0: + raise ValueError("Content in the block should be indented."\ + f"Please check the docstring: \n{summary}") + parts = [indent_code_left(part, tab_space) for part in parts] + enums = _parse_enum_content(parts) + continue + + try: + keyword = extract_keyword(part.lstrip('\n')) + except ValueError: + raise ValueError(f"Please check the docstring: \n{summary}") + # Works for both code-block and code + if keyword and keyword in [CODE, CODEBLOCK]: + # Retrieve the language found in the format of + # .. code-block:: lang + # {lang} is optional however. + language = part.split("::")[1].strip() + summary_parts.append(f"```{language}") + + code_snippet = [] + tab_space = -1 + + # Extract the name for attribute first. + elif keyword and keyword == ATTRIBUTE: + found_name = False + name = part.split("::")[1].strip() + + # Extracts the notice content and format it. + elif keyword and keyword in NOTICES: + summary_parts.append(f'