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

feat: adding single language build support #44

Merged
merged 6 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .trampolinerc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pass_down_envvars+=(
"SOURCE_BLOB" # Set to force regeneration of a single source blob.
"FORCE_GENERATE_ALL" # Set to force regeneration of all blobs.
"TEST_BUCKET" # Must set when running tests.
"LANGUAGE" # For specifying specific language builds.
dandhlee marked this conversation as resolved.
Show resolved Hide resolved
)

# Prevent unintentional override on the default image.
Expand Down
16 changes: 16 additions & 0 deletions docpipeline/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ def build_one_doc(bucket_name, object_name, credentials):
log.error(e)
sys.exit(1)

@main.command()
@click.argument("bucket_name")
@click.argument("language")
@click.option(
"--credentials",
default=credentials.find(),
help="Path to the credentials file to use for Google Cloud Storage.",
)
def build_language_docs(bucket_name, language, credentials):
verify(credentials)

try:
generate.build_language_docs(bucket_name, language, credentials)
except Exception as e:
log.error(e)
sys.exit(1)

if __name__ == "__main__":
main()
6 changes: 6 additions & 0 deletions docpipeline/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,9 @@ def build_new_docs(bucket_name, credentials):
if new_name not in other_names:
new_blobs.append(blob)
build_blobs(new_blobs, credentials)

def build_language_docs(bucket_name, language, credentials):
dandhlee marked this conversation as resolved.
Show resolved Hide resolved
all_blobs = storage_client(credentials).list_blobs(bucket_name)
language_prefix = DOCFX_PREFIX+language+"-"
docfx_blobs = [blob for blob in all_blobs if blob.name.startswith(language_prefix)]
build_blobs(docfx_blobs, credentials)
2 changes: 2 additions & 0 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ python3 -m pip install .

if [ "$FORCE_GENERATE_ALL" == "true" ]; then
python3 docpipeline/__main__.py build-all-docs $SOURCE_BUCKET
elif [ -n "$LANGUAGE" ]; then
python3 docpipeline/__main__.py build-language-docs $SOURCE_BUCKET $LANGUAGE
elif [ -n "$SOURCE_BLOB" ]; then
python3 docpipeline/__main__.py build-one-doc $SOURCE_BUCKET $SOURCE_BLOB
else
Expand Down