MCPcopy Index your code
hub / github.com/idank/explainshell / get_manpage_text

Function get_manpage_text

explainshell/extraction/llm/text.py:45–60  ·  view source on GitHub ↗

Run patched ``mandoc -T markdown `` to get markdown directly.

(gz_path: str)

Source from the content-addressed store, hash-verified

43
44
45def get_manpage_text(gz_path: str) -> str:
46 """Run patched ``mandoc -T markdown <gz_path>`` to get markdown directly."""
47 if not os.path.isfile(gz_path):
48 raise FileNotFoundError(f"manpage file not found: {gz_path}")
49 result = subprocess.run(
50 [config.MANDOC_PATH, "-T", "markdown", gz_path],
51 capture_output=True,
52 text=True,
53 timeout=60,
54 )
55 if result.returncode != 0 or not result.stdout.strip():
56 raise ExtractionError(
57 f"mandoc failed for {gz_path}: {result.stderr}",
58 reason_class=FailureReason.MANDOC_FAILED,
59 )
60 return result.stdout.strip()
61
62
63def _split_sections(text: str) -> list[tuple[int, str]]:

Calls 1

ExtractionErrorClass · 0.90