Skip to content

Commit

Permalink
Fixed three bugs. First was a conflit between the include command and…
Browse files Browse the repository at this point in the history
… other syntax (this was fixed in the markdown-include code, really). Next was fixing the way FORD would crash if a one-line bit of documentation contained a colon. Finally, I cought and fixed a problem whereby FORD would split lines with semicolons, even if those semicolons were inside a string.
  • Loading branch information
cmacmackin committed Jan 17, 2015
1 parent ed70022 commit a9e2026
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ doc/
src/
README.rst
FORD.egg-info/
dist/
dist/
wiki/
26 changes: 5 additions & 21 deletions ford/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@


import re
import ford.utils

#FIXME: Can get rid of the blank line that is inserted after any documentation.
#FIXME: Do I need the docbuffer variable? Could I just put that contents into the pending list?

class FortranReader(object):
Expand Down Expand Up @@ -119,29 +119,13 @@ def next(self):
(len(linebuffer) > 0))

# Split buffer with semicolons
match = self.SC_RE.match(linebuffer)
while match:
portion = match.group(1).strip()
if len(portion) > 0: self.pending.append(portion)
leftover = match.group(2).strip()
match = FortranReader.SC_RE.match(leftover)
if not match:
if len(leftover) > 0: self.pending.append(leftover)
frags = ford.utils.quote_split(';',linebuffer)
self.pending.extend([ s.strip() for s in frags if len(s) > 0])

# Return the line
if len(self.pending) > 0:
if self.prevdoc:
self.prevdoc = False
return ""
else:
return self.pending.pop(0)
elif len(linebuffer) > 0:
if self.prevdoc:
self.prevdoc = False
self.pending.append(linebuffer)
return ""
else:
return linebuffer
self.prevdoc = False
return self.pending.pop(0)
else:
tmp = self.docbuffer
self.docbuffer = ""
Expand Down
6 changes: 5 additions & 1 deletion ford/sourceform.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ def markdown(self,md):
Process the documentation with Markdown to produce HTML.
"""
if len(self.doc) > 0:
if len(self.doc) == 1 and ':' in self.doc[0]:
words = self.doc[0].split(':')[0].strip()
if words.lower() not in ['author','date','license','version','category','summary','deprecated']:
self.doc.insert(0,'')
self.doc.append('')
self.doc = '\n'.join(self.doc)
self.doc = md.convert(self.doc)
self.meta = md.Meta
Expand Down Expand Up @@ -391,7 +396,6 @@ def correlate(self,project):
var.correlate(project)
if hasattr(self,'args'):
for arg in self.args:
#~ print arg, self.name
arg.correlate(project)
if hasattr(self,'retvar'):
#~ print self.name, self.retvar, self.parent.parent.name
Expand Down
32 changes: 32 additions & 0 deletions ford/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,35 @@ def paren_split(sep,string):
return retlist



def quote_split(sep,string):
"""
Splits the strings into pieces divided by sep, when sep in not inside quotes.
"""
if len(sep) != 1: raise Exception("Separation string must be one character long")
retlist = []
squote = False
dquote = False
left = 0
i = 0
while i < len(string):
if string[i] == '"' and not dquote:
if not squote:
squote = True
elif (i+1) < len(string) and string[i+1] == '"':
i += 1
else:
squote = False
elif string[i] == "'" and not squote:
if not dquote:
dquote = True
elif (i+1) < len(string) and string[i+1] == "'":
i += 1
else:
dquote = False
elif string[i] == sep and not dquote and not squote:
retlist.append(string[left:i])
left = i + 1
i += 1
retlist.append(string[left:])
return retlist
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
name = 'FORD',
packages = ['ford'],
include_package_data = True,
version = '0.4',
version = '0.5',
description = 'FORD, standing for FORtran Documenter, is an automatic documentation generator for modern Fortran programs.',
long_description = long_description,
author = 'Chris MacMackin',
Expand Down Expand Up @@ -42,7 +42,7 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
],
install_requires = ['markdown','markdown-include','toposort','jinja2',
install_requires = ['markdown','markdown-include >= 0.2','toposort','jinja2',
'pygments','beautifulsoup4'],
entry_points = {
'console_scripts': [
Expand Down

0 comments on commit a9e2026

Please sign in to comment.