[PATCH 1 of 4] extensions: obtain docs by importing modules instead of parsing them

Dan Villiom Podlaski Christiansen danchr at gmail.com
Fri Jul 31 04:08:42 CDT 2009


On 31/07/2009, at 08.06, Cédric Duval wrote:

> # HG changeset patch
> # User Cédric Duval <cedricduval at free.fr>
> # Date 1248811268 -7200
> # Node ID be5a81430dd6903ac1497315cc49e0456d568a12
> # Parent  25255ce87bcfb753df078b2f8cabc6bcb5cb96ce
> extensions: obtain docs by importing modules instead of parsing them

Are you certain that this is safe? I wrote up a small sed script to  
remove documentation, and from what I can tell some of the extensions  
actually modify Mercurial at load. Third party extensions are likely  
to do it too; so far, extension authors have been able to rely on  
their modules not being loaded unless the exception itself is loaded  
and enabled.

The output of the script follows below, and I've attached the script  
itself too.

--

Dan Villiom Podlaski Christiansen
danchr at gmail.com


=============
% for i in *.py */__init__.py; ../contrib/filter-pydoc.sed $i | egrep - 
v '^(import|from|class|def|#)' | sed -n "s|^[^[:space:]]|${${i:r}%%/ 
*}: &|p"
bookmarks: cmdtable = {
bookmarks: }
bugzilla: MySQLdb = None
children: cmdtable = {
children: }
churn: cmdtable = {
churn: }
color: _effect_params = {'none': 0,
color: _status_abbreviations = { 'M': 'modified',
color: _status_effects = { 'modified': ['blue', 'bold'],
color: _patch_effects = { 'applied': ['blue', 'bold', 'underline'],
color: _diff_prefixes = [('diff', 'diffline'),
color: _diff_effects = {'diffline': ['bold'],
color: _ui = None
extdiff: cmdtable = {
fetch: cmdtable = {
fetch: }
gpg: cmdtable = {
gpg: }
graphlog: ASCIIDATA = 'ASC'
graphlog: cmdtable = {
graphlog: }
hgcia: socket_timeout = 30 # seconds
hgcia: try:
hgcia: except:
hgcia: HGCIA_VERSION = '0.1'
hgcia: HGCIA_URL = 'http://hg.kublai.com/mercurial/hgcia'
hgk: cmdtable = {
hgk: }
interhg: orig_escape = templatefilters.filters["escape"]
interhg: interhg_table = []
interhg: templatefilters.filters["escape"] = interhg_escape
interhg: extensions.wrapfunction(hgweb_mod.hgweb, 'refresh',  
interhg_refresh)
keyword: commands.optionalrepo += ' kwdemo'
keyword: nokwcommands = ('add addremove annotate bundle copy export  
grep incoming init'
keyword: restricted = 'merge record resolve qfold qimport qnew qpush  
qrefresh qrecord'
keyword: kwtools = {'templater': None, 'hgcmd': '', 'inc': [], 'exc':  
['.hg*']}
keyword: cmdtable = {
keyword: }
mq: commands.norepo += " qclone"
mq: normname = util.normpath
mq: seriesopts = [('s', 'summary', None, _('print first line of patch  
header'))]
mq: qcloneopts = [('p', 'patches', 'patches',
mq: queueopts =  [('',  'queue', None,
mq: cmdtable = {
mq: }
notify: }
patchbomb: emailopts = [
patchbomb: cmdtable = {
patchbomb: }
purge: cmdtable = {
purge: }
rebase: )
rebase: cmdtable = {
rebase: "rebase":
rebase: }
record: lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@ 
\s*(.*)')
record: cmdtable = {
record: }
share: cmdtable = {
share: }
share: commands.norepo += " share"
transplant: cmdtable = {
transplant: }
win32text: re_single_lf = re.compile('(^|[^\r])\n', re.MULTILINE)
win32text: newlinestr = {'\r\n': 'CRLF', '\r': 'CR'}
win32text: filterstr = {'\r\n': 'clever', '\r': 'mac'}
win32text: _filters = {
convert: commands.norepo += " debugsvnlog debugcvsps"
convert: commands.optionalrepo += " convert"
convert: cmdtable = {
convert: }
highlight: extensions.wrapfunction(webcommands, '_filerevision',  
filerevision_highlight)
highlight: extensions.wrapfunction(webcommands, 'annotate',  
annotate_highlight)
highlight: webcommands.highlightcss = generate_css
highlight: webcommands.__all__.append('highlightcss')
inotify: cmdtable = {
zeroconf: server = None
zeroconf: localip = None
zeroconf: extensions.wrapfunction(ui.ui, 'config', config)
zeroconf: extensions.wrapfunction(ui.ui, 'configitems', configitems)
zeroconf: hgweb_mod.hgweb = hgwebzc
zeroconf: hgwebdir_mod.hgwebdir = hgwebdirzc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: filter-pydoc.sed
Type: application/octet-stream
Size: 183 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090731/98988b9e/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1943 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090731/98988b9e/attachment.bin 


More information about the Mercurial-devel mailing list