| 65 | }, |
| 66 | ) |
| 67 | def man( |
| 68 | ctx: Context, |
| 69 | no_clean: bool = False, |
| 70 | no_color: bool = False, |
| 71 | archive: pathlib.Path = os.environ.get("ARCHIVE_FILENAME"), # type: ignore[assignment] |
| 72 | ): |
| 73 | github_output = os.environ.get("GITHUB_OUTPUT") |
| 74 | if no_clean is False: |
| 75 | ctx.run("make", "clean", cwd="doc/", check=True) |
| 76 | opts = [ |
| 77 | "-W", |
| 78 | "-j", |
| 79 | "auto", |
| 80 | "--keep-going", |
| 81 | ] |
| 82 | if no_color is False: |
| 83 | opts.append("--color") |
| 84 | ctx.run( |
| 85 | "make", |
| 86 | "man", |
| 87 | f"SPHINXOPTS={' '.join(opts)}", |
| 88 | cwd="doc/", |
| 89 | check=True, |
| 90 | ) |
| 91 | docdir = "doc/man" |
| 92 | if not os.path.exists(docdir): |
| 93 | # doc/ always exists |
| 94 | os.mkdir(docdir) |
| 95 | for root, dirs, files in os.walk("doc/_build/man"): |
| 96 | for file in files: |
| 97 | shutil.copy(os.path.join(root, file), os.path.join(docdir, file)) |
| 98 | |
| 99 | artifact = tools.utils.REPO_ROOT / "doc" / "man" |
| 100 | if "LATEST_RELEASE" in os.environ: |
| 101 | artifact_name = f"salt-{os.environ['LATEST_RELEASE']}-docs-man" |
| 102 | else: |
| 103 | artifact_name = "salt-docs-man" |
| 104 | |
| 105 | if archive is not None: |
| 106 | ctx.info(f"Compressing the generated documentation to '{archive}'...") |
| 107 | ctx.run("tar", "caf", str(archive.resolve()), ".", cwd="doc/man") |
| 108 | |
| 109 | if github_output is not None: |
| 110 | with open(github_output, "a", encoding="utf-8") as wfh: |
| 111 | wfh.write( |
| 112 | "has-artifacts=true\n" |
| 113 | f"artifact-name={archive.resolve().name}\n" |
| 114 | f"artifact-path={archive.resolve()}\n" |
| 115 | ) |
| 116 | elif github_output is not None: |
| 117 | with open(github_output, "a", encoding="utf-8") as wfh: |
| 118 | wfh.write( |
| 119 | "has-artifacts=true\n" |
| 120 | f"artifact-name={artifact.resolve().name}\n" |
| 121 | f"artifact-path={artifact.resolve()}\n" |
| 122 | ) |
| 123 | |
| 124 | |