[PATCH v7 06/24] check-variable-fonts.py: add a helper to display instructions

Mauro Carvalho Chehab posted 24 patches 2 weeks ago
There is a newer version of this series
[PATCH v7 06/24] check-variable-fonts.py: add a helper to display instructions
Posted by Mauro Carvalho Chehab 2 weeks ago
Use lib docstring to output the comments via --help/-h. With
that, update the default instructions to recomment it instead
of asking the user to read the source code.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 tools/docs/check-variable-fonts.py | 7 +++++++
 tools/docs/lib/latex_fonts.py      | 8 ++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/docs/check-variable-fonts.py b/tools/docs/check-variable-fonts.py
index 79b28f0f7d85..ae274e7fbbb7 100755
--- a/tools/docs/check-variable-fonts.py
+++ b/tools/docs/check-variable-fonts.py
@@ -12,10 +12,17 @@ Detect problematic Noto CJK variable fonts.
 or more details, see lib/latex_fonts.py.
 """
 
+import argparse
 import sys
 
 from lib.latex_fonts import LatexFontChecker
 
+checker = LatexFontChecker()
+
+parser=argparse.ArgumentParser(description=checker.description(),
+                               formatter_class=argparse.RawTextHelpFormatter)
+_=parser.parse_args()
+
 msg = LatexFontChecker().check()
 if msg:
     print(msg)
diff --git a/tools/docs/lib/latex_fonts.py b/tools/docs/lib/latex_fonts.py
index e03412e3947e..0a3ad4995e79 100755
--- a/tools/docs/lib/latex_fonts.py
+++ b/tools/docs/lib/latex_fonts.py
@@ -113,6 +113,9 @@ class LatexFontChecker:
 
         self.re_cjk = re.compile(r"([^:]+):\s*Noto\s+(Sans|Sans Mono|Serif) CJK")
 
+    def description(self):
+        return __doc__
+
     def get_noto_cjk_vf_fonts(self):
         """Get Noto CJK fonts"""
 
@@ -154,8 +157,9 @@ class LatexFontChecker:
                 For CJK pages in PDF, they need to be hidden from XeTeX by denylisting.
                 Or, CJK pages can be skipped by uninstalling texlive-xecjk.
 
-                For more info on denylisting, other options, and variable font, see header
-                comments of {rel_file}.
+                For more info on denylisting, other options, and variable font, run:
+
+                    tools/docs/check-variable-fonts.py -h
             """)
         msg += "=" * 77
 
-- 
2.51.0