Skip to content

Commit 84d4561

Browse files
docs: support python3 to generate docs (googleapis#801)
Co-authored-by: Bu Sun Kim <[email protected]>
1 parent 43fc0cf commit 84d4561

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

describe.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,10 @@ def document_collection_recursive(resource, path, root_discovery, discovery):
348348
html = document_collection(resource, path, root_discovery, discovery)
349349

350350
f = open(os.path.join(FLAGS.dest, path + "html"), "w")
351-
f.write(html.encode("utf-8"))
351+
if sys.version_info.major < 3:
352+
html = html.encode("utf-8")
353+
354+
f.write(html)
352355
f.close()
353356

354357
for name in dir(resource):
@@ -450,7 +453,10 @@ def document_api_from_discovery_document(uri):
450453
markdown.append("\n")
451454

452455
with open("docs/dyn/index.md", "w") as f:
453-
f.write("\n".join(markdown).encode("utf-8"))
456+
markdown = "\n".join(markdown)
457+
if sys.version_info.major < 3:
458+
markdown = markdown.encode("utf-8")
459+
f.write(markdown)
454460

455461
else:
456462
sys.exit("Failed to load the discovery document.")

0 commit comments

Comments
 (0)