MCPcopy
hub / github.com/saltstack/salt / man

Function man

tools/docs.py:67–122  ·  view source on GitHub ↗
(
    ctx: Context,
    no_clean: bool = False,
    no_color: bool = False,
    archive: pathlib.Path = os.environ.get("ARCHIVE_FILENAME"),  # type: ignore[assignment]
)

Source from the content-addressed store, hash-verified

65 },
66)
67def 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

Callers

nothing calls this directly

Calls 8

openFunction · 0.50
getMethod · 0.45
runMethod · 0.45
appendMethod · 0.45
existsMethod · 0.45
copyMethod · 0.45
infoMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected