Re: [PATCH 4 of 6] i18n: use saved object to get actual function information if available
On Tue, 22 Aug 2017 04:18:17 +0900, FUJIWARA Katsunori wrote: > At Mon, 21 Aug 2017 21:46:35 +0900, > Yuya Nishihara wrote: > > > > On Wed, 16 Aug 2017 01:19:04 +0900, FUJIWARA Katsunori wrote: > > > # HG changeset patch > > > # User FUJIWARA Katsunori> > > # Date 1502792844 -32400 > > > # Tue Aug 15 19:27:24 2017 +0900 > > > # Node ID b6dd19c795147e675b9caf58383b6cafd3f03534 > > > # Parent 1d204d17d51eb143f1ef66426cec1831cd8c93bf > > > # Available At https://bitbucket.org/foozy/mercurial-wip > > > # hg pull https://bitbucket.org/foozy/mercurial-wip -r > > > b6dd19c79514 > > > # EXP-Topic i18n-fix-update-pot-issues > > > i18n: use saved object to get actual function information if available > > > > > > To list up available compression types instead of > > > ".. bundlecompressionmarker" in "hg help bundlespec" output, proxy > > > object "docobject" is used, because: > > > > > > - current online help system requires that __doc__ of registered > > > object (maybe, function) is already well formatted in reST syntax > > > > > > - bundletype() method of compressionengine classes is used to list up > > > available compression types, but > > > > > > - __doc__ of bundletype() object (= "instancemethod") is read-only > > > > Just curious. Any reason why we can't make the bundletype.__doc__ statically > > formatted? > > Would you suppose change like below ? > > > diff --git a/mercurial/util.py b/mercurial/util.py > --- a/mercurial/util.py > +++ b/mercurial/util.py > @@ -3425,7 +3425,8 @@ class _zlibengine(compressionengine): > return 'zlib' > > def bundletype(self): > -"""zlib compression using the DEFLATE algorithm. > +"""``zlib`` > +zlib compression using the DEFLATE algorithm. > > All Mercurial clients should support this format. The compression > algorithm strikes a reasonable balance between compression ratio > Yes. > If we keep extensibility of compression algorithms, this kind of > manual formatting causes broken help output easily, IMHO. > > Though, I don't know any plan or actual implementation of compression > type other than built-in ones :-) I prefer keeping things simple until they actually be a problem. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 4 of 6] i18n: use saved object to get actual function information if available
At Mon, 21 Aug 2017 21:46:35 +0900, Yuya Nishihara wrote: > > On Wed, 16 Aug 2017 01:19:04 +0900, FUJIWARA Katsunori wrote: > > # HG changeset patch > > # User FUJIWARA Katsunori> > # Date 1502792844 -32400 > > # Tue Aug 15 19:27:24 2017 +0900 > > # Node ID b6dd19c795147e675b9caf58383b6cafd3f03534 > > # Parent 1d204d17d51eb143f1ef66426cec1831cd8c93bf > > # Available At https://bitbucket.org/foozy/mercurial-wip > > # hg pull https://bitbucket.org/foozy/mercurial-wip -r > > b6dd19c79514 > > # EXP-Topic i18n-fix-update-pot-issues > > i18n: use saved object to get actual function information if available > > > > To list up available compression types instead of > > ".. bundlecompressionmarker" in "hg help bundlespec" output, proxy > > object "docobject" is used, because: > > > > - current online help system requires that __doc__ of registered > > object (maybe, function) is already well formatted in reST syntax > > > > - bundletype() method of compressionengine classes is used to list up > > available compression types, but > > > > - __doc__ of bundletype() object (= "instancemethod") is read-only > > Just curious. Any reason why we can't make the bundletype.__doc__ statically > formatted? Would you suppose change like below ? diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -3425,7 +3425,8 @@ class _zlibengine(compressionengine): return 'zlib' def bundletype(self): -"""zlib compression using the DEFLATE algorithm. +"""``zlib`` +zlib compression using the DEFLATE algorithm. All Mercurial clients should support this format. The compression algorithm strikes a reasonable balance between compression ratio If we keep extensibility of compression algorithms, this kind of manual formatting causes broken help output easily, IMHO. Though, I don't know any plan or actual implementation of compression type other than built-in ones :-) -- -- [FUJIWARA Katsunori] fo...@lares.dti.ne.jp ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 4 of 6] i18n: use saved object to get actual function information if available
On Wed, 16 Aug 2017 01:19:04 +0900, FUJIWARA Katsunori wrote: > # HG changeset patch > # User FUJIWARA Katsunori> # Date 1502792844 -32400 > # Tue Aug 15 19:27:24 2017 +0900 > # Node ID b6dd19c795147e675b9caf58383b6cafd3f03534 > # Parent 1d204d17d51eb143f1ef66426cec1831cd8c93bf > # Available At https://bitbucket.org/foozy/mercurial-wip > # hg pull https://bitbucket.org/foozy/mercurial-wip -r > b6dd19c79514 > # EXP-Topic i18n-fix-update-pot-issues > i18n: use saved object to get actual function information if available > > To list up available compression types instead of > ".. bundlecompressionmarker" in "hg help bundlespec" output, proxy > object "docobject" is used, because: > > - current online help system requires that __doc__ of registered > object (maybe, function) is already well formatted in reST syntax > > - bundletype() method of compressionengine classes is used to list up > available compression types, but > > - __doc__ of bundletype() object (= "instancemethod") is read-only Just curious. Any reason why we can't make the bundletype.__doc__ statically formatted? ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 4 of 6] i18n: use saved object to get actual function information if available
# HG changeset patch # User FUJIWARA Katsunori# Date 1502792844 -32400 # Tue Aug 15 19:27:24 2017 +0900 # Node ID b6dd19c795147e675b9caf58383b6cafd3f03534 # Parent 1d204d17d51eb143f1ef66426cec1831cd8c93bf # Available At https://bitbucket.org/foozy/mercurial-wip # hg pull https://bitbucket.org/foozy/mercurial-wip -r b6dd19c79514 # EXP-Topic i18n-fix-update-pot-issues i18n: use saved object to get actual function information if available To list up available compression types instead of ".. bundlecompressionmarker" in "hg help bundlespec" output, proxy object "docobject" is used, because: - current online help system requires that __doc__ of registered object (maybe, function) is already well formatted in reST syntax - bundletype() method of compressionengine classes is used to list up available compression types, but - __doc__ of bundletype() object (= "instancemethod") is read-only On the other hand, hggettext requires original function object, in order to get document location in source code. Therefore, description of each compression types isn't yet translatable. Even if translatable, translators should make much effort to determine location of original texts in source code. To get actual function information, this patch makes hggettext use function object saved as "_origfunc", if it is available. This patch also changes bundlecompressiontopics() side, in order to explain how these changes work easily. This patch is a part of preparations for making description of each compression types translatable. diff --git a/i18n/hggettext b/i18n/hggettext --- a/i18n/hggettext +++ b/i18n/hggettext @@ -119,6 +119,8 @@ def docstrings(path): for func, rstrip in functions: if func.__doc__: +docobj = func # this might be a proxy to provide formatted doc +func = getattr(func, '_origfunc', func) funcmod = inspect.getmodule(func) extra = '' if funcmod.__package__ == funcmod.__name__: @@ -128,8 +130,8 @@ def docstrings(path): src = inspect.getsource(func) name = "%s.%s" % (actualpath, func.__name__) lineno = inspect.getsourcelines(func)[1] -doc = func.__doc__ -origdoc = getattr(func, '_origdoc', '') +doc = docobj.__doc__ +origdoc = getattr(docobj, '_origdoc', '') if rstrip: doc = doc.rstrip() origdoc = origdoc.rstrip() diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -3752,6 +3752,8 @@ def bundlecompressiontopics(): value = docobject() value.__doc__ = doc +value._origdoc = engine.bundletype.__doc__ +value._origfunc = engine.bundletype items[bt[0]] = value ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel