MCPcopy
hub / github.com/idank/explainshell / manpage

Function manpage

explainshell/web/views.py:151–174  ·  view source on GitHub ↗

Serve the raw manpage source text via exact lookup. *rest* is everything after distro/release, e.g. "1/cd.1posix", mapping to source key "ubuntu/26.04/1/cd.1posix.gz".

(distro, release, rest)

Source from the content-addressed store, hash-verified

149
150@debug_bp.route("/manpage/<distro>/<release>/<path:rest>")
151def manpage(distro, release, rest):
152 """Serve the raw manpage source text via exact lookup.
153
154 *rest* is everything after distro/release, e.g. "1/cd.1posix",
155 mapping to source key "ubuntu/26.04/1/cd.1posix.gz".
156 """
157 source = f"{distro}/{release}/{rest}.gz"
158 raw = get_store().get_raw_manpage(source)
159 if raw is None:
160 return render_template(
161 "errors/missingmanpage.html",
162 title="missing man page",
163 e=errors.ProgramDoesNotExist(rest),
164 )
165
166 is_markdown = "markdown" in raw.generator
167 name, sec = util.name_section(os.path.basename(source)[:-3])
168 return render_template(
169 "manpage.html",
170 program=f"{name}({sec})",
171 source_text=raw.source_text,
172 source_html=render_markdown(raw.source_text) if is_markdown else None,
173 is_markdown=is_markdown,
174 )
175
176
177@bp.route("/explain", defaults={"path": ""})

Callers

nothing calls this directly

Calls 4

get_storeFunction · 0.90
render_markdownFunction · 0.90
get_raw_manpageMethod · 0.80
name_sectionMethod · 0.80

Tested by

no test coverage detected