diff --git a/CHANGELOG.md b/CHANGELOG.md index 36d28e2..88ed0e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,4 @@ * BUGFIX - * add missing default for `role_dir` - * fix value mapping in jinja2 source dict - * add missing exception handling for dict merge - * fix handling of multiline default values in template + * add `role_name` config option to overwrite name of the role * FEATURE - * use explicit marker to convert annotation values to json - * use dictsort filter in template for ordered variable list + * add basic hugo theme diff --git a/ansibledoctor/Config.py b/ansibledoctor/Config.py index e1560b4..844f165 100644 --- a/ansibledoctor/Config.py +++ b/ansibledoctor/Config.py @@ -41,6 +41,11 @@ class Config(): "env": "ROLE_DIR", "type": environs.Env().str }, + "role_name": { + "default": "", + "env": "ROLE_NAME", + "type": environs.Env().str + }, "dry_run": { "default": False, "env": "DRY_RUN", @@ -168,6 +173,9 @@ class Config(): for key, item in self.SETTINGS.items(): normalized = self._add_dict_branch(normalized, key.split("."), item["default"]) + # compute role_name default + normalized["role_name"] = os.path.basename(self.role_dir) + self.schema = anyconfig.gen_schema(normalized) return normalized diff --git a/ansibledoctor/DocumentationParser.py b/ansibledoctor/DocumentationParser.py index f2cb685..c1f1595 100644 --- a/ansibledoctor/DocumentationParser.py +++ b/ansibledoctor/DocumentationParser.py @@ -55,7 +55,7 @@ class Parser: if data.get("dependencies") is not None: self._data["meta"]["dependencies"] = {"value": data.get("dependencies")} - self._data["meta"]["name"] = {"value": os.path.basename(self.config.role_dir)} + self._data["meta"]["name"] = {"value": self.config.config["role_name"]} except (ruamel.yaml.composer.ComposerError, ruamel.yaml.scanner.ScannerError) as e: message = "{} {}".format(e.context, e.problem) self.log.sysexit_with_message("Unable to read yaml file {}\n{}".format(rfile, message)) diff --git a/docs/content/configuration/defaults.md b/docs/content/configuration/defaults.md index ac32d09..2534e6f 100644 --- a/docs/content/configuration/defaults.md +++ b/docs/content/configuration/defaults.md @@ -6,6 +6,8 @@ title: Default settings --- # default is your current working dir role_dir: +# default is the basename of 'role_name' +role_name: # don't write anything to filesystem dry_run: False diff --git a/docs/content/configuration/env.md b/docs/content/configuration/env.md index 5e09eaf..0ba225c 100644 --- a/docs/content/configuration/env.md +++ b/docs/content/configuration/env.md @@ -5,6 +5,7 @@ title: Environment Variables {{< highlight Shell "linenos=table" >}} ANSIBLE_DOCTOR_CONFIG_FILE= ANSIBLE_DOCTOR_ROLE_DIR= +ANSIBLE_DOCTOR_ROLE_NAME= ANSIBLE_DOCTOR_DRY_RUN=false ANSIBLE_DOCTOR_LOG_LEVEL=warning ANSIBLE_DOCTOR_LOG_JSON=false