Changeset 5df0bec in rtems-central


Ignore:
Timestamp:
Mar 17, 2020, 1:28:07 PM (17 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
78ef906
Parents:
64987c4
git-author:
Sebastian Huber <sebastian.huber@…> (03/17/20 13:28:07)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/17/20 15:32:51)
Message:

applconfig: Rework

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • config.ini

    r64987c4 r5df0bec  
    1111    - external/rtems-docs/eng
    1212    target: external/rtems-docs/eng/glossary.rst
     13appl-config:
     14  groups:
     15  - uid: RTEMS-ACFG-BDBUF
     16    target: external/rtems-docs/c-user/config/bdbuf.rst
     17  - uid: RTEMS-ACFG-CLASSIC
     18    target: external/rtems-docs/c-user/config/classic-api.rst
     19  - uid: RTEMS-ACFG-CLASSICINIT
     20    target: external/rtems-docs/c-user/config/classic-init-task.rst
     21  - uid: RTEMS-ACFG-DEVDRV
     22    target: external/rtems-docs/c-user/config/device-driver.rst
     23  - uid: RTEMS-ACFG-EVENTRECORD
     24    target: external/rtems-docs/c-user/config/event-record.rst
     25  - uid: RTEMS-ACFG-FILESYSTEM
     26    target: external/rtems-docs/c-user/config/filesystem.rst
     27  - uid: RTEMS-ACFG-GENERAL
     28    target: external/rtems-docs/c-user/config/general.rst
     29  - uid: RTEMS-ACFG-IDLE
     30    target: external/rtems-docs/c-user/config/idle-task.rst
     31  - uid: RTEMS-ACFG-MPCI
     32    target: external/rtems-docs/c-user/config/mpci.rst
     33  - uid: RTEMS-ACFG-POSIX
     34    target: external/rtems-docs/c-user/config/posix-api.rst
     35  - uid: RTEMS-ACFG-POSIXINIT
     36    target: external/rtems-docs/c-user/config/posix-init-thread.rst
     37  - uid: RTEMS-ACFG-SCHEDGENERAL
     38    target: external/rtems-docs/c-user/config/scheduler-general.rst
     39  - uid: RTEMS-ACFG-STACKALLOC
     40    target: external/rtems-docs/c-user/config/task-stack-alloc.rst
  • rtems_spec_to_x.py

    r64987c4 r5df0bec  
    2828import yaml
    2929
     30import rtemsqual.applconfig
    3031import rtemsqual.items
    3132import rtemsqual.glossary
     
    3839    item_cache = rtemsqual.items.ItemCache(config["spec"])
    3940    rtemsqual.glossary.generate(config["glossary"], item_cache)
     41    rtemsqual.applconfig.generate(config["appl-config"], item_cache)
    4042
    4143
  • rtemsqual/applconfig.py

    r64987c4 r5df0bec  
    2525# POSSIBILITY OF SUCH DAMAGE.
    2626
    27 import rtemsqual.content
     27from typing import Dict
     28
     29from rtemsqual.content import SphinxContent
     30from rtemsqual.items import Item, ItemCache
     31
     32ItemMap = Dict[str, Item]
    2833
    2934
    30 def _application_configuration_option_content(item, content):
    31     content.add_index_entries(item["index"])
    32     content.add_blank_line()
    33     header = item["header"]
    34     content.add_label(header)
    35     content.add_blank_line()
    36     content.add_header(header)
    37     content.add_definition_item("DESCRIPTION:",
    38                                 item["description"].split("\n"))
    39     content.add_definition_item("NOTES:", item["notes"].split("\n"))
     35def _gather_groups(item: Item, groups: ItemMap) -> None:
     36    for child in item.children:
     37        _gather_groups(child, groups)
     38    if item["type"] == "interface" and item[
     39            "interface-type"] == "appl-config-group":
     40        groups[item.uid] = item
    4041
    4142
    42 def _application_configuration_group_content(item, document):
    43     content = rtemsqual.content.SphinxContent()
     43def _gather_options(item: Item, options: ItemMap) -> None:
    4444    for child in item.children:
    45         if (child["type"] == "interface" and
    46                 child["interface-type"] == "application-configuration-option"):
    47             _application_configuration_option_content(child, content)
    48         else:
    49             raise Exception("unexpected item type")
     45        _gather_options(child, options)
     46    if item["type"] == "interface" and item[
     47            "interface-type"] == "appl-config-option":
     48        options[item.uid] = item
    5049
    5150
    52 def classic_api_guide_content(item, document):
    53     """ This is work in progress. """
    54     for child in item.children:
    55         if (child["type"] == "interface" and
    56                 child["interface-type"] == "application-configuration-group"):
    57             _application_configuration_group_content(child, document)
    58         else:
    59             classic_api_guide_content(child, document)
     51def _generate_content(group: Item, options: ItemMap) -> SphinxContent:
     52    content = SphinxContent()
     53    group.register_license_and_copyrights(content)
     54    content.add_header(group["appl-config-group-name"], level="=")
     55    content.add_blank_line()
     56    content.add_lines(group["appl-config-group-description"])
     57    for item in sorted(options.values(), key=lambda x: x.uid):
     58        name = item["appl-config-option-name"]
     59        item.register_license_and_copyrights(content)
     60        content.add_index_entries([name] + item["appl-config-option-index"])
     61        content.add_blank_line()
     62        content.add_label(name)
     63        content.add_blank_line()
     64        content.add_header(name, level="-")
     65        content.add_definition_item("CONSTANT:", f"``{name}``")
     66        content.add_definition_item("DATA TYPE:",
     67                                    item["appl-config-option-data-type"])
     68        content.add_definition_item("RANGE:", item["appl-config-option-range"])
     69        content.add_definition_item("DEFAULT VALUE:",
     70                                    item["appl-config-option-default-value"])
     71        content.add_definition_item("DESCRIPTION:",
     72                                    item["appl-config-option-description"])
     73        content.add_definition_item("NOTES:", item["appl-config-option-notes"])
     74    content.add_licence_and_copyrights()
     75    return content
     76
     77
     78def generate(config: dict, item_cache: ItemCache) -> None:
     79    """
     80    Generates application configuration documentation sources according to the
     81    configuration.
     82
     83    :param config: A dictionary with configuration entries.
     84    :param item_cache: The specification item cache containing the application
     85                       configuration groups and options.
     86    """
     87    groups = {}  # type: ItemMap
     88    for item in item_cache.top_level.values():
     89        _gather_groups(item, groups)
     90
     91    for group_config in config["groups"]:
     92        group = groups[group_config["uid"]]
     93        options = {}  # type: ItemMap
     94        _gather_options(group, options)
     95        content = _generate_content(group, options)
     96        content.write(group_config["target"])
Note: See TracChangeset for help on using the changeset viewer.