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

Function manpage_url

explainshell/web/views.py:386–403  ·  view source on GitHub ↗

Resolve a manpage source path to an external URL, or None.

(source)

Source from the content-addressed store, hash-verified

384
385
386def manpage_url(source):
387 """Resolve a manpage source path to an external URL, or None."""
388 parts = source.split("/")
389 section_dir = parts[-2] # e.g. "1" from "ubuntu/26.04/1/cat.1posix.gz"
390 basename = parts[-1]
391 name_with_section = basename[:-3] # remove .gz
392 name, section = name_with_section.rsplit(".", 1)
393
394 best_match = None
395 best_len = 0
396 for prefix, template in config.MANPAGE_URLS.items():
397 if source.startswith(prefix + "/") and len(prefix) > best_len:
398 best_match = template
399 best_len = len(prefix)
400
401 if best_match:
402 return best_match.format(section=section, section_dir=section_dir, name=name)
403 return None
404
405
406def explain_program(program, store, distro=None, release=None):

Callers 6

test_matching_prefixMethod · 0.90
test_no_matchMethod · 0.90
test_section_8Method · 0.90
test_posix_sectionMethod · 0.90
explain_programFunction · 0.85
explain_cmdFunction · 0.85

Calls

no outgoing calls

Tested by 4

test_matching_prefixMethod · 0.72
test_no_matchMethod · 0.72
test_section_8Method · 0.72
test_posix_sectionMethod · 0.72