mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 06:05:29 -04:00
Docs: Add warning for bad usage strings
This commit is contained in:
parent
fb643211e1
commit
6e8e403088
2 changed files with 19 additions and 0 deletions
|
|
@ -311,6 +311,11 @@ def render_keyword(
|
|||
location = get_text(keyword.find("LOCATION"))
|
||||
lone_keyword_value = get_text(keyword.find("LONE_KEYWORD_VALUE"))
|
||||
|
||||
# Check that the usage string starts with one of the keyword names.
|
||||
if keyword.tag == "KEYWORD" and usage:
|
||||
if not any(usage.upper().startswith(n) for n in keyword_names):
|
||||
print(f"Warning: Keyword {keyword_xref} has bad usage: {location}")
|
||||
|
||||
# Find keyword data type.
|
||||
data_type_element = keyword.find("DATA_TYPE")
|
||||
assert data_type_element is not None
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ CONTAINS
|
|||
CHARACTER(len=*), INTENT(in), OPTIONAL :: deprecation_notice
|
||||
LOGICAL, INTENT(in), OPTIONAL :: removed
|
||||
|
||||
CHARACTER(LEN=default_string_length) :: tmp_string
|
||||
INTEGER :: i, n
|
||||
LOGICAL :: check
|
||||
|
||||
|
|
@ -221,6 +222,19 @@ CONTAINS
|
|||
IF (PRESENT(usage)) THEN
|
||||
CPASSERT(LEN_TRIM(usage) <= LEN(keyword%usage))
|
||||
keyword%usage = usage
|
||||
! Check that the usage string starts with one of the keyword names.
|
||||
IF (keyword%names(1) /= "_SECTION_PARAMETERS_" .AND. keyword%names(1) /= "_DEFAULT_KEYWORD_") THEN
|
||||
tmp_string = usage
|
||||
CALL uppercase(tmp_string)
|
||||
check = .FALSE.
|
||||
DO i = 1, SIZE(keyword%names)
|
||||
check = check .OR. (INDEX(tmp_string, TRIM(keyword%names(i))) == 1)
|
||||
END DO
|
||||
!TODO: Arm this check once all the existing usage strings have been fixed.
|
||||
!IF (.NOT. check) THEN
|
||||
! CPABORT("Usage string must start with one of the keyword name.")
|
||||
!END IF
|
||||
END IF
|
||||
ELSE
|
||||
keyword%usage = ""
|
||||
END IF
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue