Help system for ABACUS INPUT parameters.
More...
#include <input_help.h>
|
| static void | initialize () |
| | Initialize the help registry from generated data.
|
| |
| static bool | show_parameter_help (const std::string &key, std::ostream &os=std::cout) |
| | Display detailed help for a specific parameter.
|
| |
| static std::vector< std::string > | search_parameters (const std::string &query) |
| | Search for parameters matching a query string.
|
| |
| static void | show_general_help (std::ostream &os=std::cout) |
| | Display general help message.
|
| |
| static void | generate_yaml (std::ostream &os=std::cout) |
| | Generate YAML dump of all parameter metadata.
|
| |
| static ParameterMetadata | get_metadata (const std::string &key) |
| | Get metadata for a specific parameter.
|
| |
| static std::vector< std::string > | find_similar_parameters (const std::string &query, int max_suggestions=5, int max_distance=3) |
| | Find similar parameter names for fuzzy matching.
|
| |
|
| static void | build_registry () |
| | Build the registry from generated PARAMETER_DATA.
|
| |
| static std::map< std::string, ParameterMetadata >::const_iterator | find_case_insensitive (const std::string &key) |
| | Find parameter with case-insensitive matching.
|
| |
| static std::string | to_lowercase (const std::string &str) |
| | Convert string to lowercase for case-insensitive comparison.
|
| |
| static int | levenshtein_distance (const std::string &s1, const std::string &s2) |
| | Calculate Levenshtein distance between two strings.
|
| |
Help system for ABACUS INPUT parameters.
This class provides functionality to search for and display help information about INPUT parameters. The parameter data is loaded from auto-generated code that parses the documentation at build time.
◆ build_registry()
| void ModuleIO::ParameterHelp::build_registry |
( |
| ) |
|
|
staticprivate |
Build the registry from generated PARAMETER_DATA.
This is called once during initialization to populate the registry from the static constexpr data array. Thread-safe via std::call_once.
◆ find_case_insensitive()
| std::map< std::string, ParameterMetadata >::const_iterator ModuleIO::ParameterHelp::find_case_insensitive |
( |
const std::string & |
key | ) |
|
|
staticprivate |
Find parameter with case-insensitive matching.
Uses pre-computed lowercase mappings for O(log n) performance.
- Parameters
-
| key | The parameter name to look up (any case) |
- Returns
- Iterator to the parameter in registry_, or registry_.end() if not found
◆ find_similar_parameters()
| std::vector< std::string > ModuleIO::ParameterHelp::find_similar_parameters |
( |
const std::string & |
query, |
|
|
int |
max_suggestions = 5, |
|
|
int |
max_distance = 3 |
|
) |
| |
|
static |
Find similar parameter names for fuzzy matching.
Uses a multi-tier matching strategy to find relevant parameters:
- Prefix matches (e.g., "relax" matches "relax_new") - highest priority
- Substring matches (e.g., "cut" matches "ecutwfc") - medium priority
- Levenshtein distance for typos - lowest priority
This ensures semantic relevance: typing "relax" suggests "relax_method" instead of random 5-letter parameters like "nelec".
- Parameters
-
| query | The parameter name to find similar matches for |
| max_suggestions | Maximum number of suggestions to return (default: 5) |
| max_distance | Maximum edit distance for fuzzy matches (default: 3) |
- Returns
- Vector of similar parameter names sorted by relevance
◆ generate_yaml()
| void ModuleIO::ParameterHelp::generate_yaml |
( |
std::ostream & |
os = std::cout | ) |
|
|
static |
Generate YAML dump of all parameter metadata.
Outputs a YAML document suitable for documentation generation. Each parameter includes name, category, type, description, default_value, unit, and availability fields.
- Parameters
-
| os | Output stream to write YAML to (default: std::cout) |
◆ get_metadata()
Get metadata for a specific parameter.
Returns a copy of the parameter metadata. Check if the returned metadata has a non-empty name to verify the parameter was found.
- Parameters
-
| key | The parameter name to look up (case-insensitive) |
- Returns
- ParameterMetadata with empty name if not found, otherwise the parameter metadata
Example: auto meta = ParameterHelp::get_metadata("ecutwfc"); if (!meta.name.empty()) { // Parameter found, use meta.description, etc. }
◆ initialize()
| void ModuleIO::ParameterHelp::initialize |
( |
| ) |
|
|
static |
Initialize the help registry from generated data.
This function is called automatically on first use. It builds the parameter registry from the generated PARAMETER_DATA array.
◆ levenshtein_distance()
| int ModuleIO::ParameterHelp::levenshtein_distance |
( |
const std::string & |
s1, |
|
|
const std::string & |
s2 |
|
) |
| |
|
staticprivate |
Calculate Levenshtein distance between two strings.
Returns the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into another.
- Parameters
-
| s1 | First string |
| s2 | Second string |
- Returns
- Edit distance between the strings
◆ search_parameters()
| std::vector< std::string > ModuleIO::ParameterHelp::search_parameters |
( |
const std::string & |
query | ) |
|
|
static |
Search for parameters matching a query string.
Performs case-insensitive substring matching on parameter names.
- Parameters
-
| query | The search query string |
- Returns
- Vector of matching parameter names (sorted alphabetically)
◆ show_general_help()
| void ModuleIO::ParameterHelp::show_general_help |
( |
std::ostream & |
os = std::cout | ) |
|
|
static |
Display general help message.
Shows usage information and lists commonly used parameters.
- Parameters
-
| os | Output stream to write to (default: std::cout) |
◆ show_parameter_help()
| bool ModuleIO::ParameterHelp::show_parameter_help |
( |
const std::string & |
key, |
|
|
std::ostream & |
os = std::cout |
|
) |
| |
|
static |
Display detailed help for a specific parameter.
- Parameters
-
| key | The parameter name to look up (case-insensitive) |
| os | Output stream to write to (default: std::cout) |
- Returns
- true if parameter was found and help was displayed, false otherwise
◆ to_lowercase()
| std::string ModuleIO::ParameterHelp::to_lowercase |
( |
const std::string & |
str | ) |
|
|
staticprivate |
Convert string to lowercase for case-insensitive comparison.
◆ init_flag_
| std::once_flag ModuleIO::ParameterHelp::init_flag_ |
|
staticprivate |
◆ lowercase_to_actual_
| std::map< std::string, std::string > ModuleIO::ParameterHelp::lowercase_to_actual_ |
|
staticprivate |
◆ registry_
The documentation for this class was generated from the following files:
- /home/runner/work/abacus-develop/abacus-develop/source/source_io/input_help.h
- /home/runner/work/abacus-develop/abacus-develop/source/source_io/input_help.cpp