Skip to content

Commit

Permalink
Add settings table generator in dochelpers. (#585)
Browse files Browse the repository at this point in the history
* - Add a documentation helper to auto-generate a settings table for
  software docuementation.

- Add the MOVEABLE flag to the control and plenum blocks in the
  `refSmallReactorBase`.

- Update the description of the crStartingHeight assembly parameter.

* Add unit test for `generatePluginSettingsTable`.
  • Loading branch information
jakehader authored Mar 1, 2022
1 parent 53d64ab commit a3f23ed
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
4 changes: 3 additions & 1 deletion armi/reactor/assemblyParameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ def detailedNDens(self, value):
units="cm",
description="The initial starting position of the bottom of the control "
"material when starting control operations as measured from the 0 point in the "
"reactor model",
"reactor model. Note that the starting height is taken to be a maximum withdrawn "
"location for the control rod for determining the position when the control rod "
"is fully withdrawn.",
)

with pDefs.createBuilder() as pb:
Expand Down
4 changes: 2 additions & 2 deletions armi/tests/refSmallReactorBase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ blocks:
ip: duct.op
mult: 1.0
op: 16.75
control: &block_control
moveable control: &block_control
control:
shape: Circle
material: B4C
Expand Down Expand Up @@ -197,7 +197,7 @@ blocks:
id: 0.0
mult: shield.mult
od: 0.10056
plenum: &block_plenum
moveable plenum: &block_plenum
clad:
shape: Circle
material: HT9
Expand Down
37 changes: 37 additions & 0 deletions armi/utils/dochelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,40 @@ def generateParamTable(klass, fwParams, app=None):
content.append(pluginContent + "\n")

return "\n".join(content)


def generatePluginSettingsTable(settings, pluginName):
"""
Return a string containing one or more restructured text list tables containing
settings descriptions for a plugin.
Parameters
----------
settings : list of Settings
This is a list of settings definitions, typically returned by a
``defineSettings`` plugin hook.
"""
headerContent = """
.. list-table:: Settings defined in the {}
:header-rows: 1
:widths: 20 10 50 20
* - Name
- Label
- Description
- Default Value
""".format(
pluginName
)

content = [f".. _{pluginName}-settings-table:"]
pluginContent = headerContent
for setting in settings:
default = None if setting.default == "" else setting.default
pluginContent += f""" * - ``{setting.name}``
- {setting.label}
- {setting.description}
- {default}
"""
content.append(pluginContent + "\n")
return "\n".join(content)
22 changes: 19 additions & 3 deletions armi/utils/tests/test_dochelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@

from armi.reactor import reactors
from armi.reactor import reactorParameters
from armi.utils.dochelpers import create_figure, create_table, generateParamTable
from armi.utils.dochelpers import (
create_figure,
create_table,
generateParamTable,
generatePluginSettingsTable,
)


class TestFlag(unittest.TestCase):
"""Tests for the utility Flag class and cohorts."""
class TestDocHelpers(unittest.TestCase):
"""Tests for the utility dochelpers functionns."""

def test_paramTable(self):

Expand All @@ -30,6 +35,17 @@ def test_paramTable(self):
reactorParameters.defineCoreParameters(),
)
self.assertIn("keff", table)
self.assertNotIn("notAParameter", table)

def test_settingsTable(self):
from armi.settings.fwSettings import globalSettings

table = generatePluginSettingsTable(
globalSettings.defineSettings(),
"Framework",
)
self.assertIn("numProcessors", table)
self.assertNotIn("notASetting", table)

def test_createFigure(self):
rst = create_figure(
Expand Down

0 comments on commit a3f23ed

Please sign in to comment.