commit:     39568f7c5ed4ac9531cb03e5511c809811fc517a
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Thu Nov 27 14:54:42 2025 +0000
Commit:     Brian Harring <ferringb <AT> gmail <DOT> com>
CommitDate: Thu Nov 27 14:56:53 2025 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=39568f7c

fix: ManCoverter assumed directory structure that wasn't guaranteed.

I frankly do not know why this hasn't shown elsewhere, but I can repeatedly
introduce this on my localhost.

Being I flushed this out via removing some scripts from pkgcore, I'm assuming
there is some mapping in the guts of this and via removing a script, I changed
the execution order.  Whatever it was processing first prevented it being 
visible.

Either way, read the code: this is a clear bug.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/snakeoil/dist/generate_man_rsts.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/snakeoil/dist/generate_man_rsts.py 
b/src/snakeoil/dist/generate_man_rsts.py
index ca20b36..d2fcc41 100644
--- a/src/snakeoil/dist/generate_man_rsts.py
+++ b/src/snakeoil/dist/generate_man_rsts.py
@@ -106,6 +106,11 @@ class ManConverter:
         self.parser = parser
         self.mtime = mtime
         self.replace_cmd = replace_cmd
+        self.mandir = os.path.abspath(os.path.join(self.base_path, '..', 
'man'))
+        if not os.path.exists(self.mandir):
+            os.mkdir(self.mandir)
+        elif not os.path.isdir(self.mandir):
+            raise Exception(f'man dir {self.mandir} exists, but is not a 
directory')
 
         header_chars = headers or ('=', '-', '~', '#', '*', '^')
         self.header_char = header_chars[len(name.split(' ')) - 1]
@@ -236,9 +241,8 @@ class ManConverter:
 
         if main_command:
             # generate missing, generic man page rst docs
-            mandir = os.path.abspath(os.path.join(self.base_path, '..', 'man'))
-            manpage = os.path.join(mandir, rst_filename)
-            if os.path.exists(mandir) and not os.path.isfile(manpage):
+            manpage = os.path.join(self.mandir, rst_filename)
+            if os.path.exists(self.mandir) and not os.path.isfile(manpage):
                 with open(rst_path, 'w') as f:
                     f.write(rst)
                 force_symlink(rst_path, manpage)

Reply via email to