[azpysdk] Refactor apistub so that API consistency files are the default output#47561
Conversation
There was a problem hiding this comment.
Pull request overview
This PR inverts the default behavior of azpysdk apistub so that the API consistency files (api.md and api.metadata.yml) are produced by default, aligning the command with the rest of the azpysdk checks. The previous default (raw APIView token file generation) now requires an explicit --token-file flag. The --md and --extract-metadata flags are removed, and when no --dest-dir is supplied the output now goes to the package directory (previously the staging directory). Documentation, the generate-api-markdown skill, and internal Python callers are updated accordingly.
Changes:
- Replace
--md/--extract-metadataflags with a single--token-fileopt-out; markdown + metadata generation become the default, and default output goes to the package directory. - Update internal callers (
create_api_review_pr.py,sdk_generator.py) and tests to the new invocation/behavior. - Update docs and the
generate-api-markdownskill to reflectazpysdk apistub .as the canonical command.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
eng/tools/azure-sdk-tools/azpysdk/apistub.py |
Core change: removes --md/--extract-metadata, adds --token-file, defaults to markdown+metadata generation, and writes to the package dir when no --dest-dir. |
eng/tools/azure-sdk-tools/tests/test_apistub.py |
Updates test helpers/assertions for the new token_file flag and package-directory default output. |
scripts/api_md_workflow/create_api_review_pr.py |
Drops the now-removed flags from both apistub invocations. |
eng/tools/azure-sdk-tools/packaging_tools/sdk_generator.py |
Drops the now-removed flags from the apistub invocation. |
doc/tool_usage_guide.md |
Refreshes the apistub command description. |
doc/dev/tests.md |
Documents the new default output and --token-file/--dest-dir options. |
.github/skills/generate-api-markdown/SKILL.md |
Updates skill steps to the new azpysdk apistub . command. |
A key concern: the PR removes the --md/--extract-metadata flags but does not update the API consistency workflow adapters (.github/workflows/src/api-md-consistency/adapters/python.js and api-md-consistency.js), which still invoke and advertise those flags. Since azpysdk/main.py parses arguments strictly, this would break the API consistency CI check that the PR is intended to align with.
This PR fundamentally changes the behavior of
azpysdk apistub. Due to the introduction of the api consistency check, the command to pass that consistency check used to be:Old Command
azpysdk apistub --md --extract-metadata --dest-dir .This is very inconsistent with the guidance on how to pass all other Python checks!
So now the default command is what is needed to pass the CI:
New Command
azpysdk apistub .This will generate the markdown and metadata file.
The previous default behavior, which generates the APIView token file, can be achieved by passing
--token-file.This also updates the guidance that service teams use.
Finally, this PR removes
--dest-dirwhich was broken and has surprising results. The two usage patterns that should cover all use cases are:from repo root
azpysdk apistub {packageName}from package dir
azpysdk apistub .