SettingsTable

class sharpy.utils.settings.SettingsTable[source]

Generates the documentation’s setting table at runtime.

Sphinx is our chosen documentation manager and takes docstrings in reStructuredText format. Given that the SHARPy solvers contain several settings, this class produces a table in reStructuredText format with the solver’s settings and adds it to the solver’s docstring.

This table will then be printed alongside the remaining docstrings.

To generate the table, parse the setting’s description to a solver dictionary named settings_description, in a similar fashion to what is done with settings_types and settings_default. If no description is given it will be left blank.

Then, add at the end of the solver’s class declaration method an instance of the SettingsTable class and a call to the SettingsTable.generate() method.

Examples

The end of the solver’s class declaration should contain

# Generate documentation table
settings_table = settings.SettingsTable()
__doc__ += settings_table.generate(settings_types, settings_default, settings_description)

to generate the settings table.

generate(settings_types, settings_default, settings_description, settings_options={}, header_line=None)[source]

Returns a rst-format table with the settings’ names, types, description and default values

Parameters:
  • settings_types (dict) – Setting types.

  • settings_default (dict) – Settings default value.

  • settings_description (dict) – Setting description.

  • header_line (str) – Header line description (optional)

Returns:

.rst formatted string with a table containing the settings’ information.

Return type:

str