manly icon indicating copy to clipboard operation
manly copied to clipboard

Manual manual parsing

Open Summertime opened this issue 5 years ago • 3 comments

It would be potentially better to grab the info from the manual pages directly instead of subproccing man, however we might still need to subproc man anyways to get paths


Notes

  1. man -w -> paths for man pages
    • works with man-db (fedora/debian/etc) and OpenBSD's implementation

Summertime avatar Nov 12 '18 11:11 Summertime

for bonus points, implement man -w yourself. most of the logic is in guess_manpath: https://git.savannah.gnu.org/cgit/man-db.git/tree/src/manp.c#n665 you can see it in action via man -wd

raylu avatar Nov 12 '18 18:11 raylu

Reimplementing 1400 lines of code of C to Python /can/ produce a short and beautiful program, but it is a lot of work and just a bit crazy. I would like to get rid of subprocess too. If anyone is crazy enough to attempt this, we also need to figure out how man differs on bsd...

carlbordum avatar Nov 12 '18 20:11 carlbordum

you don't need to handle most of the cases (like when PATH is empty or unset). just

  1. read /etc/manpath.config
  2. build a PATHMANPATH dict
  3. search the PATH and pull out all the relevant MANPATHs
  4. add the MANDATORY_MANPATHs
  5. ignore BSD because who cares

raylu avatar Nov 12 '18 21:11 raylu