|
19 | 19 |
|
20 | 20 | import csv |
21 | 21 | import json |
22 | | -import os |
23 | 22 | from pathlib import Path |
24 | 23 | import re |
25 | 24 | from typing import TYPE_CHECKING |
|
32 | 31 | from sphinx.environment import BuildEnvironment |
33 | 32 |
|
34 | 33 |
|
35 | | -def create_pep_json(peps: list[parser.PEP], out_dir: str) -> None: |
| 34 | +def create_pep_json(peps: list[parser.PEP]) -> str: |
36 | 35 | pep_list = [ |
37 | 36 | { |
38 | 37 | "number": pep.number, |
39 | 38 | "title": pep.title, |
40 | 39 | "authors": ", ".join(pep.authors.nick for pep.authors in pep.authors), |
| 40 | + "discussions-to": pep.discussions_to, |
41 | 41 | "status": pep.status, |
42 | 42 | "type": pep.pep_type, |
| 43 | + "created": pep.created, |
| 44 | + "python-version": pep.python_version, |
| 45 | + "post-history": pep.post_history, |
| 46 | + "resolution": pep.resolution, |
| 47 | + "requires": pep.requires, |
| 48 | + "replaces": pep.replaces, |
| 49 | + "superseded-by": pep.superseded_by, |
43 | 50 | "url": f"https://peps.python.org/pep-{pep.number:0>4}/", |
44 | 51 | } |
45 | 52 | for pep in sorted(peps) |
46 | 53 | ] |
47 | | - |
48 | | - out_file = os.path.join(out_dir, "peps.json") |
49 | | - with open(out_file, "w", encoding="UTF-8") as f: |
50 | | - json.dump(pep_list, f, indent=0) |
| 54 | + return json.dumps(pep_list, indent=0) |
51 | 55 |
|
52 | 56 |
|
53 | 57 | def create_pep_zero(app: Sphinx, env: BuildEnvironment, docnames: list[str]) -> None: |
@@ -83,4 +87,5 @@ def create_pep_zero(app: Sphinx, env: BuildEnvironment, docnames: list[str]) -> |
83 | 87 | env.found_docs.add(pep_zero_filename) |
84 | 88 |
|
85 | 89 | # Create peps.json |
86 | | - create_pep_json(peps, app.outdir) |
| 90 | + pep0_json = create_pep_json(peps) |
| 91 | + Path(app.outdir, "peps.json").write_text(pep0_json, encoding="utf-8") |
0 commit comments