Skip to content

Commit

Permalink
Merge pull request #95 from natefoo/doc-gen-fix
Browse files Browse the repository at this point in the history
Updates for settings documentation generation
  • Loading branch information
natefoo authored Dec 6, 2022
2 parents 51c34e9 + ca82885 commit 616fe39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,18 @@ The following options in the ``gravity`` section of ``galaxy.yml`` can be used t
# Consumes less memory when multiple processes are configured. Default is ``false`` if using unicornherder, else ``true``.
# preload:
# umask under which service should be executed
# umask:
# Value of supervisor startsecs, systemd TimeoutStartSec
# start_timeout: 15
# Value of supervisor stopwaitsecs, systemd TimeoutStopSec
# stop_timeout: 65
# Amount of time to wait for a server to become alive when performing rolling restarts.
# restart_timeout: 300
# Memory limit (in GB). If the service exceeds the limit, it will be killed. Default is no limit or the value of the
# ``memory_limit`` setting at the top level of the Gravity configuration, if set. Ignored if ``process_manager`` is
# ``supervisor``.
Expand Down
11 changes: 7 additions & 4 deletions gravity/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ def process_property(key, value, depth=0):
if default.endswith("\n...\n"):
default = default[: -(len("\n...\n"))]
default = default.strip()
description = "\n".join(f"{extra_white_space}# {desc}" for desc in value["description"].strip().split("\n"))
allOff = value.get("allOf", [])
if allOff and allOff[0].get("properties"):
description = "\n".join(f"{extra_white_space}# {desc}".rstrip() for desc in value["description"].strip().split("\n"))
combined = value.get("allOf", [])
if not combined and value.get("anyOf"):
# we've got a union
combined = [c for c in value["anyOf"] if c["type"] == "object"]
if combined and combined[0].get("properties"):
# we've got a nested map, add key once
description = f"{description}\n{extra_white_space}{key}:\n"
has_child = False
for item in allOff:
for item in combined:
if "enum" in item:
enum_items = [i for i in item["enum"] if not i.startswith("_")]
description = f'{description}\n{extra_white_space}# Valid options are: {", ".join(enum_items)}'
Expand Down

0 comments on commit 616fe39

Please sign in to comment.