From 375d3889de9f437bc120ade623c170198629375d Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Wed, 29 May 2024 09:44:54 -0700 Subject: [PATCH] ansible-doc: make color configurable (#83311) Signed-off-by: Abhijeet Kasurde --- changelogs/fragments/ansible-doc-color.yml | 3 ++ lib/ansible/cli/doc.py | 10 ++++- lib/ansible/config/base.yml | 48 ++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/ansible-doc-color.yml diff --git a/changelogs/fragments/ansible-doc-color.yml b/changelogs/fragments/ansible-doc-color.yml new file mode 100644 index 00000000000..045f212a58e --- /dev/null +++ b/changelogs/fragments/ansible-doc-color.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - ansible-doc - make colors configurable. diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index 084420ee69f..44fe39a597f 100755 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -71,8 +71,14 @@ NOCOLOR = { 'PLUGIN': r'[%s]', } -# TODO: make configurable -ref_style = {'MODULE': 'yellow', 'REF': 'magenta', 'LINK': 'cyan', 'DEP': 'magenta', 'CONSTANT': 'dark gray', 'PLUGIN': 'yellow'} +ref_style = { + 'MODULE': C.COLOR_DOC_MODULE, + 'REF': C.COLOR_DOC_REFERENCE, + 'LINK': C.COLOR_DOC_LINK, + 'DEP': C.COLOR_DOC_DEPRECATED, + 'CONSTANT': C.COLOR_DOC_CONSTANT, + 'PLUGIN': C.COLOR_DOC_PLUGIN, +} def jdump(text): diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml index 6e25d10d088..ea42ea5557f 100644 --- a/lib/ansible/config/base.yml +++ b/lib/ansible/config/base.yml @@ -339,6 +339,54 @@ COLOR_WARN: env: [{name: ANSIBLE_COLOR_WARN}] ini: - {key: warn, section: colors} +COLOR_DOC_MODULE: + name: Color for module name in the ansible-doc output + default: yellow + description: Defines the color to use when emitting a module name in the ansible-doc output. + env: [{name: ANSIBLE_COLOR_DOC_MODULE}] + ini: + - {key: doc_module, section: colors} + version_added: '2.18' +COLOR_DOC_REFERENCE: + name: Color for cross-reference in the ansible-doc output + default: magenta + description: Defines the color to use when emitting cross-reference in the ansible-doc output. + env: [{name: ANSIBLE_COLOR_DOC_REFERENCE}] + ini: + - {key: doc_reference, section: colors} + version_added: '2.18' +COLOR_DOC_LINK: + name: Color for Link in ansible-doc output + default: cyan + description: Defines the color to use when emitting a link in the ansible-doc output. + env: [{name: ANSIBLE_COLOR_DOC_LINK}] + ini: + - {key: doc_link, section: colors} + version_added: '2.18' +COLOR_DOC_DEPRECATED: + name: Color for deprecated value in ansible-doc output + default: magenta + description: Defines the color to use when emitting a deprecated value in the ansible-doc output. + env: [{name: ANSIBLE_COLOR_DOC_DEPRECATED}] + ini: + - {key: doc_deprecated, section: colors} + version_added: '2.18' +COLOR_DOC_CONSTANT: + name: Color for constant in ansible-doc output + default: dark gray + description: Defines the color to use when emitting a constant in the ansible-doc output. + env: [{name: ANSIBLE_COLOR_DOC_CONSTANT}] + ini: + - {key: doc_constant, section: colors} + version_added: '2.18' +COLOR_DOC_PLUGIN: + name: Color for the plugin in ansible-doc output + default: yellow + description: Defines the color to use when emitting a plugin name in the ansible-doc output. + env: [{name: ANSIBLE_COLOR_DOC_PLUGIN}] + ini: + - {key: doc_plugin, section: colors} + version_added: '2.18' CONNECTION_PASSWORD_FILE: name: Connection password file default: ~