-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Unify README embedme Usage into a Wrapper Script #21859
Merged
alzimmermsft
merged 5 commits into
Azure:master
from
alzimmermsft:AzEng_IntermediateScriptToVerifyReadmeCodesnippets
May 27, 2021
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e975267
Unify README embedme Usage into a Wrapper Script
alzimmermsft 0f2e4bd
Remove dead code
alzimmermsft b81b85b
Merge branch 'master' into AzEng_IntermediateScriptToVerifyReadmeCode…
alzimmermsft f81fae1
Use npx always, add property to parent POM to handle different relati…
alzimmermsft 29c6526
Removed commented out POM configurations
alzimmermsft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
# Python version 3.4 or higher is required to run this script. | ||
|
||
# Use case: Invokes embedme README codesnippet generation and validation regardless of OS. | ||
# | ||
# Flags | ||
# --readme/-r: Path to the README. | ||
# --verify/-v: Flag indicating to only perform a dry-run validation. | ||
# --debug/-d: Flag indicating to perform debug level logging. | ||
# | ||
# For example: Generating README codesnippets for Azure Storage Blobs. | ||
# python eng/scripts/invoke_embedme.py -r sdk/storage/azure-storage-blob/README.md | ||
# | ||
# For example: Valdate README codesnippets for Azure Core. | ||
# python eng/scripts/invoke_embedme.py -r sdk/core/azure-core/README.md -v | ||
# | ||
# The script must be run at the root of azure-sdk-for-java. | ||
|
||
import argparse | ||
import os | ||
import sys | ||
|
||
# NPX command. | ||
npx_command = 'npx embedme' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should consider specifying a version at some point here because if there is every a breaking change in that tool then we will have to deal with it. |
||
|
||
# Invoke embedme. | ||
def invoke_embedme(readme: str, verify: bool, debug: bool): | ||
command = npx_command | ||
|
||
# If the passed README path was relative | ||
command += ' ' + os.path.abspath(readme) | ||
|
||
if verify: | ||
command += ' --verify' | ||
|
||
if debug: | ||
print('Running embedme command: {}'.format(command)) | ||
|
||
sys.exit(os.system(command)) | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Invokes embedme README codesnippet generation and validation regardless of OS.') | ||
parser.add_argument('--readme', '-r', type=str, required=True, help='Path to the README') | ||
parser.add_argument('--verify', '-v', action='store_true', help='Flag indicating to only perform a dry-run validation') | ||
parser.add_argument('--debug', '-d', action='store_true', help='Flag indicating to perform debug level logging') | ||
args = parser.parse_args() | ||
|
||
invoke_embedme(args.readme, args.verify, args.debug) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. You can easily check this on run-time and throw early instead of the undefined-behavior. But not such a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just switch to that directory based on the path of this script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a standard comment in all the Python scripts used as tooling, I don't think any check the path used either.