sphinxfortran.fortran_domain – Fortran domain

A fortran domain for sphinx

class sphinxfortran.fortran_domain.FortranCallField(name, names=(), label=None, rolename=None)[source]

Bases: sphinxfortran.fortran_domain.FortranField

is_grouped = True
make_field(types, domain, items, **kwargs)[source]
class sphinxfortran.fortran_domain.FortranCompleteField(name, names=(), typenames=(), label=None, rolename=None, typerolename=None, shapenames=None, attrnames=None, prefix=None, strong=True, can_collapse=False)[source]

Bases: sphinxfortran.fortran_domain.FortranField, sphinx.util.docfields.GroupedField

A doc field that is grouped and has type information for the arguments. It always has an argument. The argument can be linked using the given rolename, the type using the given typerolename.

Two uses are possible: either parameter and type description are given separately, using a field from names and one from typenames, respectively, or both are given using a field from names, see the example.

Example:

:param foo: description of parameter foo
:type foo:  SomeClass

-- or --

:param SomeClass foo: description of parameter foo
is_typed = 2
make_field(types, domain, items, shapes=None, attrs=None, modname=None, typename=None)[source]
class sphinxfortran.fortran_domain.FortranCurrentModule(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: docutils.parsers.rst.Directive

This directive is just to tell Sphinx that we’re documenting stuff in module foo, but links to module foo won’t lead here.

final_argument_whitespace = False
has_content = False
option_spec = {}
optional_arguments = 1
required_arguments = 0
run()[source]
class sphinxfortran.fortran_domain.FortranDocFieldTransformer(directive, modname=None, typename=None)[source]

Bases: sphinx.util.docfields.DocFieldTransformer

Transforms field lists in “doc field” syntax into better-looking equivalents, using the field type definitions given on a domain.

preprocess_fieldtypes(types)[source]
scan_fieldarg(fieldname)[source]

Extract type, name, shape and attributes from a field name.

Some possible syntaxes:
 
  • p name
  • p type name(shape) [attr1,attr2]
  • p type name
  • p name [attr1, attr2]
Returns:

name, shape, type, list of attributes. if no shape is specified, it is set to None,

transform(node)[source]

Transform a single field list node.

class sphinxfortran.fortran_domain.FortranDomain(env)[source]

Bases: sphinx.domains.Domain

Fortran language domain.

clear_doc(docname)[source]
directives = {'function': <class 'sphinxfortran.fortran_domain.FortranWithSig'>, 'currentmodule': <class 'sphinxfortran.fortran_domain.FortranCurrentModule'>, 'subroutine': <class 'sphinxfortran.fortran_domain.FortranWithSig'>, 'autoroutine': <class 'sphinxfortran.fortran_autodoc.FortranAutoObjectDirective'>, 'autosrcfile': <class 'sphinxfortran.fortran_autodoc.FortranAutoSrcfileDirective'>, 'module': <class 'sphinxfortran.fortran_domain.FortranModule'>, 'autofunction': <class 'sphinxfortran.fortran_autodoc.FortranAutoFunctionDirective'>, 'program': <class 'sphinxfortran.fortran_domain.FortranProgram'>, 'autoprogram': <class 'sphinxfortran.fortran_autodoc.FortranAutoProgramDirective'>, 'variable': <class 'sphinxfortran.fortran_domain.FortranObject'>, 'automodule': <class 'sphinxfortran.fortran_autodoc.FortranAutoModuleDirective'>, 'type': <class 'sphinxfortran.fortran_domain.FortranType'>, 'autosubroutine': <class 'sphinxfortran.fortran_autodoc.FortranAutoSubroutineDirective'>}
find_obj(env, modname, name, role, searchorder=0)[source]

Find a Fortran object for “name”, perhaps using the given module and/or typename.

Params:
  • searchorder, optional: Start using relative search
get_objects()[source]
indices = [<class 'sphinxfortran.fortran_domain.FortranModuleIndex'>]
initial_data = {'objects': {}, 'modules': {}}
label = 'Fortran'
name = 'f'
object_types = {'function': <sphinx.domains.ObjType object at 0x7f64dbd70810>, 'subroutine': <sphinx.domains.ObjType object at 0x7f64dbd708d0>, 'module': <sphinx.domains.ObjType object at 0x7f64dbd70950>, 'program': <sphinx.domains.ObjType object at 0x7f64dbd705d0>, 'variable': <sphinx.domains.ObjType object at 0x7f64dbd70750>, 'type': <sphinx.domains.ObjType object at 0x7f64dbd70690>}
resolve_xref(env, fromdocname, builder, type, target, node, contnode)[source]
roles = {'subr': <sphinxfortran.fortran_domain.FortranXRefRole object at 0x7f64dbd70ad0>, 'var': <sphinxfortran.fortran_domain.FortranXRefRole object at 0x7f64dbd70a50>, 'func': <sphinxfortran.fortran_domain.FortranXRefRole object at 0x7f64dbd70a90>, 'prog': <sphinxfortran.fortran_domain.FortranXRefRole object at 0x7f64dbd709d0>, 'type': <sphinxfortran.fortran_domain.FortranXRefRole object at 0x7f64dbd70a10>, 'mod': <sphinxfortran.fortran_domain.FortranXRefRole object at 0x7f64dbd70b10>}
class sphinxfortran.fortran_domain.FortranField(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: docutils.parsers.rst.Directive

Directive to describe a change/addition/deprecation in a specific version.

final_argument_whitespace = True
has_content = True
option_spec = {'shape': <function parse_shape at 0x7f64dbd6d398>, 'type': <function unchanged at 0x7f64ded1f578>, 'attrs': <function unchanged at 0x7f64ded1f578>}
optional_arguments = 0
required_arguments = 1
run()[source]
class sphinxfortran.fortran_domain.FortranModule(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: docutils.parsers.rst.Directive

Directive to mark description of a new module.

final_argument_whitespace = False
has_content = False
option_spec = {'noindex': <function flag at 0x7f64ded1f488>, 'platform': <function <lambda> at 0x7f64dbd76140>, 'synopsis': <function <lambda> at 0x7f64dbd761b8>, 'deprecated': <function flag at 0x7f64ded1f488>}
optional_arguments = 0
required_arguments = 1
run()[source]
class sphinxfortran.fortran_domain.FortranModuleIndex(domain)[source]

Bases: sphinx.domains.Index

Index subclass to provide the Fortran module index.

generate(docnames=None)[source]
localname = iu'Fortran Module Index'
name = 'modindex'
shortname = iu'fortran modules'
class sphinxfortran.fortran_domain.FortranObject(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: sphinx.directives.ObjectDescription

Description of a general Fortran object.

_parens = ''
add_shape_and_attrs(signode, modname, ftype, shape, attrs)[source]
add_target_and_index(name, sig, signode)[source]
after_content()[source]
before_content()[source]
doc_field_types = [<sphinxfortran.fortran_domain.FortranCompleteField object at 0x7f64dbf94f50>, <sphinxfortran.fortran_domain.FortranCompleteField object at 0x7f64dbf94f90>, <sphinxfortran.fortran_domain.FortranCompleteField object at 0x7f64dbd70050>, <sphinxfortran.fortran_domain.FortranCompleteField object at 0x7f64dbd70150>, <sphinxfortran.fortran_domain.FortranCallField object at 0x7f64dbd701d0>, <sphinxfortran.fortran_domain.FortranCallField object at 0x7f64dbd70250>]
get_index_text(modname, name)[source]
get_signature_prefix(sig)[source]

May return a prefix to put before the object name in the signature.

handle_signature(sig, signode)[source]

Transform a Fortran signature into RST nodes. Returns (fully qualified name of the thing, classname if any).

If inside a class, the current class name is handled intelligently: * it is stripped from the displayed name if present * it is added to the full name (return value) if not present

needs_arglist()[source]

May return true if an empty argument list is to be generated even if the document contains none.

option_spec = {'noindex': <function flag at 0x7f64ded1f488>, 'shape': <function parse_shape at 0x7f64dbd6d398>, 'type': <function unchanged at 0x7f64ded1f578>, 'attrs': <function unchanged at 0x7f64ded1f578>, 'module': <function unchanged at 0x7f64ded1f578>}
stopwords = set(['integer', 'float', 'character', 'long', 'double'])
class sphinxfortran.fortran_domain.FortranProgram(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: sphinxfortran.fortran_domain.FortranSpecial, sphinxfortran.fortran_domain.WithFortranDocFieldTransformer, sphinxfortran.fortran_domain.FortranObject

class sphinxfortran.fortran_domain.FortranSpecial[source]
get_signature_prefix(sig)[source]

May return a prefix to put before the object name in the signature.

class sphinxfortran.fortran_domain.FortranType(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: sphinxfortran.fortran_domain.FortranSpecial, sphinxfortran.fortran_domain.WithFortranDocFieldTransformer, sphinxfortran.fortran_domain.FortranObject

before_content()[source]
class sphinxfortran.fortran_domain.FortranTypeField(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: sphinxfortran.fortran_domain.FortranObject

before_content()[source]
class sphinxfortran.fortran_domain.FortranWithSig(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: sphinxfortran.fortran_domain.FortranSpecial, sphinxfortran.fortran_domain.WithFortranDocFieldTransformer, sphinxfortran.fortran_domain.FortranObject

Description of a function of subroutine

_parens = '()'
get_signature_prefix(sig)[source]

May return a prefix to put before the object name in the signature.

needs_arglist()[source]
class sphinxfortran.fortran_domain.FortranXRefRole(fix_parens=False, lowercase=False, nodeclass=None, innernodeclass=None, warn_dangling=False)[source]

Bases: sphinx.roles.XRefRole

class sphinxfortran.fortran_domain.WithFortranDocFieldTransformer[source]
run()[source]

Same as sphinx.directives.ObjectDescription() but using FortranDocFieldTransformer

sphinxfortran.fortran_domain._pseudo_parse_arglist(signode, arglist)[source]

“Parse” a list of arguments separated by commas.

Arguments can have “optional” annotations given by enclosing them in brackets. Currently, this will split at any comma, even if it’s inside a string literal (e.g. default argument value).

sphinxfortran.fortran_domain.add_shape(node, shape, modname=None, nodefmt=<class 'docutils.nodes.Text'>)[source]

Format a shape expression for a node

sphinxfortran.fortran_domain.convert_arithm(node, expr, modname=None, nodefmt=<class 'docutils.nodes.Text'>)[source]

Format an arithmetic expression for a node

sphinxfortran.fortran_domain.parse_shape(shape)[source]
sphinxfortran.fortran_domain.re_fieldname_match()

match(string[, pos[, endpos]]) –> match object or None. Matches zero or more characters at the beginning of the string

sphinxfortran.fortran_domain.setup(app)[source]