changeset 46516:921e1253c8ba

gendoc: support defaults on customopts a bit better Without this, a customopt will very likely render like this: ``` -foo does foo (default: <hgext.myextension.MyOpt object at 0x7f31...>) ``` I copied this logic from how this is handled in mercurial/help.py. Differential Revision: https://phab.mercurial-scm.org/D9988
author Kyle Lippincott <spectral@google.com>
date Fri, 12 Feb 2021 11:04:03 -0800
parents cd9154343160
children eb36f7a71291
files doc/gendoc.py
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/doc/gendoc.py	Wed Feb 10 09:49:50 2021 -0800
+++ b/doc/gendoc.py	Fri Feb 12 11:04:03 2021 -0800
@@ -31,6 +31,7 @@
     commands,
     encoding,
     extensions,
+    fancyopts,
     help,
     minirst,
     pycompat,
@@ -86,6 +87,8 @@
         if b'\n' in desc:
             # only remove line breaks and indentation
             desc = b' '.join(l.lstrip() for l in desc.split(b'\n'))
+        if isinstance(default, fancyopts.customopt):
+            default = default.getdefaultvalue()
         if default:
             default = stringutil.forcebytestr(default)
             desc += _(b" (default: %s)") % default