Skip to content

Commit 56667a3

Browse files
authored
Merge branch 'main' into set-output
2 parents 77b29ef + 915a4fe commit 56667a3

File tree

1,454 files changed

+126352
-27854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,454 files changed

+126352
-27854
lines changed

.coveragerc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[report]
2-
omit = */samples/*
2+
omit =
3+
*/samples/*
4+
# Issue tracked in https://github.com/googleapis/google-api-python-client/issues/2132
5+
describe.py
36
exclude_lines =
47
# Re-enable the standard pragma
58
pragma: NO COVER

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
working-directory: ./scripts
8484

8585
- name: Create PR
86-
uses: actions/[email protected].0
86+
uses: actions/[email protected].1
8787
with:
8888
github-token: ${{secrets.YOSHI_CODE_BOT_TOKEN}}
8989
script: |

CHANGELOG.md

+209
Large diffs are not rendered by default.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ The following libraries will be installed when you install the client library:
110110
* [uritemplate](https://github.com/sigmavirus24/uritemplate)
111111

112112
For development you will also need the following libraries:
113-
* [WebTest](http://webtest.pythonpaste.org/en/latest/index.html)
113+
* [WebTest](https://pypi.org/project/WebTest/)
114114
* [pyopenssl](https://pypi.python.org/pypi/pyOpenSSL)
115115

116116
## Contributing

describe.py

100755100644
+35-10
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from googleapiclient.http import build_http
3939

4040
DISCOVERY_DOC_DIR = (
41-
pathlib.Path(__file__).parent.resolve()
41+
pathlib.Path(__file__).resolve().parent
4242
/ "googleapiclient"
4343
/ "discovery_cache"
4444
/ "documents"
@@ -134,7 +134,7 @@
134134
<code><a href="#$name">$name($params)</a></code></p>
135135
<p class="firstline">$firstline</p>"""
136136

137-
BASE = pathlib.Path(__file__).parent.resolve() / "docs" / "dyn"
137+
BASE = pathlib.Path(__file__).resolve().parent / "docs" / "dyn"
138138

139139
DIRECTORY_URI = "https://www.googleapis.com/discovery/v1/apis"
140140

@@ -356,7 +356,12 @@ def document_collection(resource, path, root_discovery, discovery, css=CSS):
356356

357357

358358
def document_collection_recursive(
359-
resource, path, root_discovery, discovery, doc_destination_dir
359+
resource,
360+
path,
361+
root_discovery,
362+
discovery,
363+
doc_destination_dir,
364+
artifact_destination_dir=DISCOVERY_DOC_DIR,
360365
):
361366
html = document_collection(resource, path, root_discovery, discovery)
362367

@@ -380,10 +385,13 @@ def document_collection_recursive(
380385
root_discovery,
381386
discovery["resources"].get(dname, {}),
382387
doc_destination_dir,
388+
artifact_destination_dir,
383389
)
384390

385391

386-
def document_api(name, version, uri, doc_destination_dir):
392+
def document_api(
393+
name, version, uri, doc_destination_dir, artifact_destination_dir=DISCOVERY_DOC_DIR
394+
):
387395
"""Document the given API.
388396
389397
Args:
@@ -392,6 +400,8 @@ def document_api(name, version, uri, doc_destination_dir):
392400
uri (str): URI of the API's discovery document
393401
doc_destination_dir (str): relative path where the reference
394402
documentation should be saved.
403+
artifact_destination_dir (str): relative path where the discovery
404+
artifacts should be saved.
395405
"""
396406
http = build_http()
397407
resp, content = http.request(
@@ -405,7 +415,7 @@ def document_api(name, version, uri, doc_destination_dir):
405415
discovery = json.loads(content)
406416
service = build_from_document(discovery)
407417
doc_name = "{}.{}.json".format(name, version)
408-
discovery_file_path = DISCOVERY_DOC_DIR / doc_name
418+
discovery_file_path = artifact_destination_dir / doc_name
409419
revision = None
410420

411421
pathlib.Path(discovery_file_path).touch(exist_ok=True)
@@ -445,16 +455,21 @@ def document_api(name, version, uri, doc_destination_dir):
445455
discovery,
446456
discovery,
447457
doc_destination_dir,
458+
artifact_destination_dir,
448459
)
449460

450461

451-
def document_api_from_discovery_document(discovery_url, doc_destination_dir):
462+
def document_api_from_discovery_document(
463+
discovery_url, doc_destination_dir, artifact_destination_dir=DISCOVERY_DOC_DIR
464+
):
452465
"""Document the given API.
453466
454467
Args:
455468
discovery_url (str): URI of discovery document.
456469
doc_destination_dir (str): relative path where the reference
457470
documentation should be saved.
471+
artifact_destination_dir (str): relative path where the discovery
472+
artifacts should be saved.
458473
"""
459474
http = build_http()
460475
response, content = http.request(discovery_url)
@@ -471,16 +486,23 @@ def document_api_from_discovery_document(discovery_url, doc_destination_dir):
471486
discovery,
472487
discovery,
473488
doc_destination_dir,
489+
artifact_destination_dir,
474490
)
475491

476492

477-
def generate_all_api_documents(directory_uri=DIRECTORY_URI, doc_destination_dir=BASE):
493+
def generate_all_api_documents(
494+
directory_uri=DIRECTORY_URI,
495+
doc_destination_dir=BASE,
496+
artifact_destination_dir=DISCOVERY_DOC_DIR,
497+
):
478498
"""Retrieve discovery artifacts and fetch reference documentations
479499
for all apis listed in the public discovery directory.
480500
args:
481501
directory_uri (str): uri of the public discovery directory.
482502
doc_destination_dir (str): relative path where the reference
483503
documentation should be saved.
504+
artifact_destination_dir (str): relative path where the discovery
505+
artifacts should be saved.
484506
"""
485507
api_directory = collections.defaultdict(list)
486508
http = build_http()
@@ -493,6 +515,7 @@ def generate_all_api_documents(directory_uri=DIRECTORY_URI, doc_destination_dir=
493515
api["version"],
494516
api["discoveryRestUrl"],
495517
doc_destination_dir,
518+
artifact_destination_dir,
496519
)
497520
api_directory[api["name"]].append(api["version"])
498521

@@ -513,7 +536,7 @@ def generate_all_api_documents(directory_uri=DIRECTORY_URI, doc_destination_dir=
513536
)
514537
markdown.append("\n")
515538

516-
with open(BASE / "index.md", "w") as f:
539+
with open(doc_destination_dir / "index.md", "w") as f:
517540
markdown = "\n".join(markdown)
518541
f.write(markdown)
519542

@@ -525,9 +548,11 @@ def generate_all_api_documents(directory_uri=DIRECTORY_URI, doc_destination_dir=
525548
FLAGS = parser.parse_args(sys.argv[1:])
526549
if FLAGS.discovery_uri:
527550
document_api_from_discovery_document(
528-
discovery_url=FLAGS.discovery_uri, doc_destination_dir=FLAGS.dest
551+
discovery_url=FLAGS.discovery_uri,
552+
doc_destination_dir=FLAGS.dest,
529553
)
530554
else:
531555
generate_all_api_documents(
532-
directory_uri=FLAGS.directory_uri, doc_destination_dir=FLAGS.dest
556+
directory_uri=FLAGS.directory_uri,
557+
doc_destination_dir=FLAGS.dest,
533558
)

0 commit comments

Comments
 (0)