Skip to content

Commit

Permalink
pw_docgen: Ensure UTF-8 parsing of SEED metadata file
Browse files Browse the repository at this point in the history
Change-Id: I3416ca77d625e1449260c70179189ceb99151497
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/244172
Commit-Queue: Rob Mohr <[email protected]>
Lint: Lint 🤖 <[email protected]>
Docs-Not-Needed: Alexei Frolov <[email protected]>
Reviewed-by: Rob Mohr <[email protected]>
  • Loading branch information
frolv authored and CQ Bot Account committed Oct 23, 2024
1 parent efda99e commit ade685e
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions pw_docgen/py/pw_docgen/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,35 +74,35 @@ def _main():
seed_toctree = []

for metadata_file in args.seed_metadata:
with open(metadata_file, 'r') as file:
meta = json.load(file)

if 'changelist' in meta:
# The SEED has not yet been merged and points to an active CL.
change_link = (
'https://pigweed-review.googlesource.com'
f'/c/pigweed/pigweed/+/{meta["changelist"]}'
)
title = f'`{meta["title"]} <{change_link}>`__'
seed_toctree.append(
f'{meta["number"]}: {meta["title"]}<{change_link}>',
)
else:
# The SEED document is in the source tree.
title = f':ref:`{meta["title"]} <seed-{meta["number"]}>`'
seed_toctree.append(Path(meta["rst_file"]).stem)

facilitator = meta.get('facilitator', 'Unassigned')

seed_table.extend(
[
f' * - {meta["number"]}',
f' - {title}',
f' - {_status_badge(meta["status"])}',
f' - {meta["author"]}',
f' - {facilitator}',
]
contents = Path(metadata_file).read_text(encoding='utf-8')
meta = json.loads(contents)

if 'changelist' in meta:
# The SEED has not yet been merged and points to an active CL.
change_link = (
'https://pigweed-review.googlesource.com'
f'/c/pigweed/pigweed/+/{meta["changelist"]}'
)
title = f'`{meta["title"]} <{change_link}>`__'
seed_toctree.append(
f'{meta["number"]}: {meta["title"]}<{change_link}>',
)
else:
# The SEED document is in the source tree.
title = f':ref:`{meta["title"]} <seed-{meta["number"]}>`'
seed_toctree.append(Path(meta["rst_file"]).stem)

facilitator = meta.get('facilitator', 'Unassigned')

seed_table.extend(
[
f' * - {meta["number"]}',
f' - {title}',
f' - {_status_badge(meta["status"])}',
f' - {meta["author"]}',
f' - {facilitator}',
]
)

table = '\n'.join(seed_table)

Expand All @@ -118,7 +118,7 @@ def _main():
)
# fmt: on

args.output.write_text(f'{table}\n\n{toctree}')
args.output.write_text(f'{table}\n\n{toctree}', encoding='utf-8')


if __name__ == '__main__':
Expand Down

0 comments on commit ade685e

Please sign in to comment.