Skip to content

Commit

Permalink
Fix for correct rendering of dimensions of allocatable arrays (#39)
Browse files Browse the repository at this point in the history
* Add escaping of star for dimensions for rst

* Accept fortran types in two words (e.g. double precision)

* import print function for CI tests with different python versions
  • Loading branch information
sradanov authored Mar 2, 2022
1 parent 556cf58 commit b2d6ced
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sphinxfortran/fortran_autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ def format_argfield(self, blockvar, role=None, block=None):

vdim = self.format_argdim(blockvar)
if ':' in vdim:
vdim = vdim.replace(':', '*')
vdim = vdim.replace(':', '\*')
vattr = self.format_argattr(blockvar)
vdesc = blockvar['desc'] if 'desc' in blockvar else ''
optional = 'attrspec' in blockvar and 'optional' in blockvar['attrspec'] and 'depend' not in blockvar
Expand Down
7 changes: 6 additions & 1 deletion sphinxfortran/fortran_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ def add_shape(node, shape, modname=None, nodefmt=nodes.Text):

re_name_shape = re.compile(r'(\w+)(\(.+\))?')

# The regular expression to get the different arg fields from :param:
# Make double precision an acceptable type
# re_fieldname_match = re.compile(
# r'(?P<type>\b(?:double precision|\w+)\b(?P<kind>\s*\(.*\))?)?\s*(?P<name>\b\w+\b)\s*(?P<shape>\(.*\))?\s*(?P<sattrs>\[.+\])?').match
# Accept all types in two words
re_fieldname_match = re.compile(
r'(?P<type>\b\w+\b(?P<kind>\s*\(.*\))?)?\s*(?P<name>\b\w+\b)\s*(?P<shape>\(.*\))?\s*(?P<sattrs>\[.+\])?').match
r'(?P<type>\b\w+ ?(?:\w+)?\b(?P<kind>\s*\(.*\))?)?\s*(?P<name>\b\w+\b)\s*(?P<shape>\(.*\))?\s*(?P<sattrs>\[.+\])?').match


class FortranField(Field):
Expand Down

0 comments on commit b2d6ced

Please sign in to comment.