D9988: gendoc: support defaults on customopts a bit better

spectral (Kyle Lippincott) phabricator at mercurial-scm.org
Fri Feb 12 20:05:46 UTC 2021


spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9988

AFFECTED FILES
  doc/gendoc.py

CHANGE DETAILS

diff --git a/doc/gendoc.py b/doc/gendoc.py
--- a/doc/gendoc.py
+++ b/doc/gendoc.py
@@ -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



To: spectral, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list