Skip to content

Commit 1c86c20

Browse files
ericandrewlewisidank
authored andcommitted
add some inline documentation
1 parent 00ab6f4 commit 1c86c20

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

explainshell/fixer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
from explainshell import util
44

55
class basefixer(object):
6+
'''The base fixer class which other fixers inherit from.
7+
8+
Subclasses override the base methods in order to fix manpage content during
9+
different parts of the parsing/classifying/saving process.'''
610
runbefore = []
711
runlast = False
812

@@ -36,6 +40,7 @@ def pre_add_manpage(self):
3640
fixerspriority = {}
3741

3842
class runner(object):
43+
'''The runner coordinates the fixers.'''
3944
def __init__(self, mctx):
4045
self.mctx = mctx
4146
self.fixers = [f(mctx) for f in fixerscls]

explainshell/manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ def run(self):
102102
assert len(mps) == 1
103103
mp = mps[0]
104104
if not self.overwrite or mp.updated:
105-
logger.info('manpage %r already in store, not overwriting it', m.name)
105+
logger.info('manpage %r already in the data store, not overwriting it', m.name)
106106
exists.append(m)
107107
continue
108108
except errors.ProgramDoesNotExist:
109109
pass
110110

111+
# the manpage is not in the data store; process and add it
111112
ctx = self.ctx(m)
112113
m = self.process(ctx)
113114
if m:

explainshell/manpage.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def _parsetext(lines):
122122
l = re.sub(_href, r'<a href="http://manpages.ubuntu.com/manpages/precise/en/man\2/\1.\2.html">', l)
123123
for lookfor, replacewith in _replacements:
124124
l = re.sub(lookfor, replacewith, l)
125+
# confirm the line is valid utf8
125126
lreplaced = l.decode('utf8', 'ignore').encode('utf8')
126127
if lreplaced != l:
127128
logger.error('line %r contains invalid utf8', l)
@@ -176,6 +177,8 @@ def __init__(self, path):
176177
self._text = None
177178

178179
def read(self):
180+
'''Read the content from a local manpage file and store it in usable formats
181+
on the class instance.'''
179182
cmd = [config.MAN2HTML, urllib.urlencode({'local' : os.path.abspath(self.path)})]
180183
logger.info('executing %r', ' '.join(cmd))
181184
self._text = subprocess.check_output(cmd, stderr=devnull, env=ENV)

0 commit comments

Comments
 (0)