Skip to content

Commit

Permalink
doc: check if directives are in CamelCase
Browse files Browse the repository at this point in the history
If Bareos config directices are not in CamelCase,
the script raises an error.
  • Loading branch information
joergsteffens committed Nov 30, 2021
1 parent b5da145 commit 860a476
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions docs/manuals/scripts/generate-resoure-descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ def convertCamelCase2Spaces(self, valueCC):
result.append(token)
return " ".join(result)

def isValidCamelCase(self, key):
if key in ("EnableVSS", "AutoXFlateOnReplication"):
return True
return re.match("^([A-Z][a-z]+)+$", key) is not None

def getDatatype(self, name):
return self.json["datatype"][name]

Expand Down Expand Up @@ -256,7 +261,6 @@ def getDescription(self, data):
description = ""
if data.get("description"):
description = self.indent(data.get("description"), 3)
# .replace('_','\_')
return description

def getConvertedResourceDirectives(self, daemon, resourcename):
Expand Down Expand Up @@ -346,6 +350,13 @@ def getRows(self, daemon, resourcename, subtree, link):
for key in sorted(filter(None, subtree.keys())):
data = BareosConfigurationSchemaDirective(subtree[key])

if not self.isValidCamelCase(key):
raise ValueError(
"The directive {} from {}/{} is not valid CamelCase.".format(
key, daemon, resourcename
)
)

strings = {
"key": self.convertCamelCase2Spaces(key),
"extra": [],
Expand All @@ -362,7 +373,9 @@ def getRows(self, daemon, resourcename, subtree, link):
if data.get("equals"):
strings["datatype"] = "= :config:datatype:`{datatype}`\ ".format(**data)
else:
strings["datatype"] = "{{ :config:datatype:`{datatype}`\ }}".format(**data)
strings["datatype"] = "{{ :config:datatype:`{datatype}`\ }}".format(
**data
)

extra = []
if data.get("alias"):
Expand Down

0 comments on commit 860a476

Please sign in to comment.