summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-05-18 08:06:00 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-05-18 08:08:07 +0200
commitf64591cf3652b644213c65e3acce26bc67bc0993 (patch)
tree312bcb5fa0e4ab8e3cd44370f40657f876ad36e5
parentb9384a1738b2eb16594ba007fec979bb16334357 (diff)
Warn if prompt contains leading or trailing whitespace
Also strip the prompt in that case. Leading/trailing whitespace in prompts leads to ugly workarounds in e.g. reStructuredText documentation, where '*prompt *' is invalid.
-rw-r--r--kconfiglib.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index b673c10..5913adc 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -2251,7 +2251,16 @@ class Kconfig(object):
self._warn("{} defined with multiple prompts in single location"
.format(_name_and_loc(node.item)))
- node.prompt = (self._expect_str(), self._parse_cond())
+ prompt = self._expect_str()
+ if prompt != prompt.strip():
+ self._warn("{} has leading or trailing whitespace in its prompt"
+ .format(_name_and_loc(node.item)))
+
+ # This avoid issues for e.g. reStructuredText documentation, where
+ # '*prompt *' is invalid
+ prompt = prompt.strip()
+
+ node.prompt = (prompt, self._parse_cond())
def _parse_help(self, node):
# Find first non-blank (not all-space) line and get its indentation