The functions used by


Given a file path to a TLO package, return the name in dot form.


dirpath – the path to the package, e.g. (1) “./src/tlo/logging/sublog” or (2) “./src/tlo”


string of package name in dot form, e.g. (1) “tlo.logging.sublog” or (2) “tlo”


Given a root directory topdir, iterates recursively over top dir and the files and subdirectories within it. Returns a dictionary with each key = path to a directory (i.e. to topdir or one of its nested subdirectories), and value = list of Python .py files in that directory.


topdir – root directory to traverse downwards from, iteratively.


dict with key = a directory, value = list of Python files in dir key.

get_classes_in_module(fqn, module_obj)[source]

Generate a list of lists of the classes defined in the required module (file), in the order in which they appear in the module file. Note that this excludes any other classes in the module, such as those brought in by inheritance, or imported.

Each entry in the list returned is itself a list of: [class name, class object, line number]

  • fqn – Fully-qualified name of the module, e.g. “tlo.methods.mockitis”

  • module_obj – an object representing this module

  • return – list of entries, each of the form: [class name, class object, line number]

get_fully_qualified_name(filename, context)[source]

Given a file name and a context return the fully-qualified name of the module

e.g. tlo.methods.mockitis This gets used in doc page title.

  • filename – name of file, e.g. “”

  • context – “location” of module, e.g. “tlo.methods”


a string, e.g. “tlo.methods.mockitis”

write_rst_file(rst_dir, fqn, mobj)[source]

We want to write one .rst file per module in ./src/tlo/methods

  • rst_dir – directory in which to write the new .rst file

  • fqn – fully-qualified module name, e.g. “tlo.methods.mockitis”

  • mobj – the module object


Generate output string for a single class to be written to an rst file.


classinfo – a list with [class name, class object, line number]


the string to output


Which functions do we want to print?


clazz – class object under consideration


returns a list of function objects we want to print

Written by Asif

extract_bases(class_name, class_obj, spacer='')[source]

Document which classes this class inherits from, except for the object class or this class itself.

  • class_name – name of the class (e.g. Mockitis) for which we want the bases

  • class_obj – object with information about this class

  • spacer – string to use as whitespace padding.


Tuple with (1) string of base(s) for this class (if any), with links to their docs. (2) the list of base class objects

get_base_string(class_name, class_obj, base_obj)[source]

For this object, representing a base class, extract its name and add a hyperlink to it. Unless it is the root ‘object’ class, or the name of the class itself.

  • class_name – the name of the class (e.g. “Mockitis”) for which obj is a base,

  • class_obj – object representing the class

  • base_obj – the object representation of the base class, e.g. <class ‘tlo.core.Module’> or <class ‘object’> or <class ‘tlo.methods.mockitis.Mockitis’>


string as hyperlink

Given a name like Mockitis and a base_string like tlo.core.Module, create a link to the latter’s doc page.

  • base_fqn – fully-qualified name of the base class, e.g. tlo.core.Module

  • base_obj – the object representing the base class


a string with the link to the base class’s place in the generated documentation.


Dynamically create a table of arbitrary length from a PROPERTIES or PARAMETERS dictionary.


mydict – the dictionary object.


A list of strings, used for output.

NB Do not change the positioning of items in the f-strings below, or things will break!

The table is returned as a list of strings. If there is no data, an empty list is returned.