diff options
| author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2024-10-10 16:21:46 +0200 |
|---|---|---|
| committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2024-10-11 10:23:19 +0200 |
| commit | 3f32944fd7993aa04f07d076d31ccb5cf433ee3a (patch) | |
| tree | b46031e47cfbae74ca5def7d0a094a4ab149c10e /tools/release_notes/main.py | |
| parent | c866be38d9c14555c897a85e5b51c5e0f8347964 (diff) | |
Release Notes: Fix for full documentation build
- Fix for full documentation build by adding a new cli option
for the output directory.
Pick-to: 6.8
Task-number: PYSIDE-2853
Change-Id: I06d76567364a4fbc37cb3f8d03a2020d93b9e513
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tools/release_notes/main.py')
| -rw-r--r-- | tools/release_notes/main.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/tools/release_notes/main.py b/tools/release_notes/main.py index b9a86172d..77ce47420 100644 --- a/tools/release_notes/main.py +++ b/tools/release_notes/main.py @@ -15,7 +15,7 @@ from argparse import ArgumentParser, RawTextHelpFormatter SECTION_NAMES = ["PySide6", "Shiboken6", "PySide2", "Shiboken2"] DIR = Path(__file__).parent -OUTPUT_DIR = Path(f"{DIR}/../../sources/pyside6/doc/release_notes").resolve() +DEFAULT_OUTPUT_DIR = Path(f"{DIR}/../../sources/pyside6/doc/release_notes").resolve() CHANGELOG_DIR = Path(f"{DIR}/../../doc/changelogs").resolve() BASE_CONTENT = """\ @@ -124,7 +124,7 @@ def parse_changelogs() -> str: return changelogs -def write_md_file(section: str, changelogs: list[Changelog]): +def write_md_file(section: str, changelogs: list[Changelog], output_dir: Path): ''' For each section create a .md file with the following content: @@ -138,7 +138,7 @@ def write_md_file(section: str, changelogs: list[Changelog]): - Change 2 .... ''' - file_path = OUTPUT_DIR / f"{section.lower()}_release_notes.md" + file_path = output_dir / f"{section.lower()}_release_notes.md" with open(file_path, 'w', encoding='utf-8') as file: file.write(f"# {section}\n") for changelog in changelogs: @@ -151,9 +151,9 @@ def write_md_file(section: str, changelogs: list[Changelog]): file.write("\n") -def generate_index_file(): +def generate_index_file(output_dir: Path): """Generate the index RST file.""" - index_path = OUTPUT_DIR / "index.rst" + index_path = output_dir / "index.rst" index_path.write_text(BASE_CONTENT, encoding='utf-8') @@ -162,21 +162,25 @@ def main(): formatter_class=RawTextHelpFormatter) parser.add_argument("-v", "--verbose", help="run in verbose mode", action="store_const", dest="loglevel", const=logging.INFO) + parser.add_argument("--target", "-t", help="Directory to output the generated files", + type=Path, default=DEFAULT_OUTPUT_DIR) args = parser.parse_args() logging.basicConfig(level=args.loglevel) + output_dir = args.target.resolve() + # create the output directory if it does not exist # otherwise remove its contents - if OUTPUT_DIR.is_dir(): - shutil.rmtree(OUTPUT_DIR, ignore_errors=True) - logging.info(f"[RELEASE_DOC] Removed existing {OUTPUT_DIR}") + if output_dir.is_dir(): + shutil.rmtree(output_dir, ignore_errors=True) + logging.info(f"[RELEASE_DOC] Removed existing {output_dir}") - logging.info(f"[RELEASE_DOC] Creating {OUTPUT_DIR}") - OUTPUT_DIR.mkdir(exist_ok=True) + logging.info(f"[RELEASE_DOC] Creating {output_dir}") + output_dir.mkdir(exist_ok=True) logging.info("[RELEASE_DOC] Generating index.md file") - generate_index_file() + generate_index_file(output_dir) logging.info("[RELEASE_DOC] Parsing changelogs") changelogs = parse_changelogs() @@ -186,7 +190,7 @@ def main(): for section in SECTION_NAMES: logging.info(f"[RELEASE_DOC] Generating {section.lower()}_release_notes.md file") - write_md_file(section, changelogs) + write_md_file(section, changelogs, output_dir) if __name__ == "__main__": |
