Skip to content

Commit bec56d9

Browse files
committed
some eyecandy
1 parent 591db83 commit bec56d9

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

doc2md.py

100644100755
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
"""
55
doc2md.py generates Python documentation in the Markdown (md) format. It was
6-
written to automatically generate documentation that can be put on Github
7-
or Bitbucket wiki pages. It is initially based on Ferry Boender's pydocmd.
6+
written to automatically generate documentation that can be put on Github
7+
or Bitbucket wiki pages. It is initially based on Ferry Boender's pydocmd.
88
99
It is as of yet not very complete and is more of a Proof-of-concept than a
1010
fully-fledged tool. Markdown is also a very restricted format and every
@@ -16,14 +16,14 @@
1616
$ python doc2md.py module [...]
1717
1818
doc2md.py scans every python file (.py) given and generates the documentation
19-
in a subfolder `doc`.
19+
in a subfolder `doc`.
2020
2121
## Example output
2222
23+
- http://github.com/blasterbug/doc2md.py/wiki/doc2md
2324
- http://github.com/blasterbug/SmileANN/wiki/neuron
2425
- http://github.com/blasterbug/SmileANN/wiki/faces
25-
- http://github.com/blasterbug/doc2md.py/wiki/doc2md
26-
26+
2727
"""
2828

2929

@@ -35,7 +35,7 @@
3535

3636

3737
__author__ = "Benjamin Sientzoff"
38-
__version__ = "0.1b"
38+
__version__ = "0.1.2b"
3939
__maintainer__ = "Benjamin Sientzoff (blasterbug)"
4040
__license__ = "GNU GPL V2"
4141

@@ -109,7 +109,7 @@ def insp_mod(mod_name, mod_inst):
109109
for func_name, func_inst in functions:
110110
if func_inst.__module__ == mod_name :
111111
info['functions'].append(insp_method(func_name, func_inst))
112-
112+
113113
# Get module classes
114114
classes = inspect.getmembers(mod_inst, inspect.isclass)
115115
if classes:
@@ -165,7 +165,7 @@ def insp_method(method_name, method_inst):
165165
for pos, default in enumerate(method_args.defaults):
166166
info['args'][a_pos + pos] = '%s=%s' % (info['args'][a_pos + pos], default)
167167

168-
# Print method documentation
168+
# Print method documentation
169169
method_doc = inspect.getdoc(method_inst)
170170
if method_doc:
171171
info['doc'] = fmt_doc(method_doc)
@@ -175,6 +175,8 @@ def insp_method(method_name, method_inst):
175175
def to_markdown( text_block ) :
176176
"""
177177
Markdownify an inspect file
178+
:param text_block: inspect file to turn to Markdown
179+
:return: Markdown doc into a string
178180
"""
179181
doc_output = ("# %s \n" % file_i['name'] )
180182
doc_output += file_i['doc'] + ' \n'
@@ -184,7 +186,7 @@ def to_markdown( text_block ) :
184186
if 'email' in file_i['author']:
185187
author += '<%s>' % (file_i['author']['email'])
186188
if author:
187-
doc_output += str(" - __Author__: %s\n" % author )
189+
doc_output += str("\n __Author__: %s \n" % author )
188190

189191
author_attrs = [
190192
('Version', 'version'),
@@ -193,7 +195,7 @@ def to_markdown( text_block ) :
193195
]
194196
for attr_friendly, attr_name in author_attrs:
195197
if attr_name in file_i['author']:
196-
doc_output += " - __%s__: %s \n" % (attr_friendly, file_i['author'][attr_name])
198+
doc_output += " __%s__: %s \n" % (attr_friendly, file_i['author'][attr_name])
197199

198200
if file_i['vars']:
199201
doc_output += "\n## Variables\n"
@@ -205,7 +207,7 @@ def to_markdown( text_block ) :
205207
for function_i in file_i['functions']:
206208
if function_i['name'].startswith('_'):
207209
continue
208-
doc_output += "\n\n### def `%s(%s)`\n" % (function_i['name'], ', '.join(function_i['args']))
210+
doc_output += "\n\n### `%s(%s)`\n" % (function_i['name'], ', '.join(function_i['args']))
209211
if function_i['doc']:
210212
doc_output += "%s" % (function_i['doc'])
211213
else:
@@ -244,5 +246,3 @@ def to_markdown( text_block ) :
244246
else:
245247
sys.stderr.write('Usage: %s <file.py>\n' % (sys.argv[0]))
246248
sys.exit(1)
247-
248-

0 commit comments

Comments
 (0)