ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Static Public Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
ModuleIO::ParameterHelp Class Reference

Help system for ABACUS INPUT parameters. More...

#include <input_help.h>

Collaboration diagram for ModuleIO::ParameterHelp:

Static Public Member Functions

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 Private Member Functions

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.
 

Static Private Attributes

static std::map< std::string, ParameterMetadataregistry_
 
static std::map< std::string, std::string > lowercase_to_actual_
 
static std::once_flag init_flag_
 

Detailed Description

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.

Member Function Documentation

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
keyThe parameter name to look up (any case)
Returns
Iterator to the parameter in registry_, or registry_.end() if not found
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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:

  1. Prefix matches (e.g., "relax" matches "relax_new") - highest priority
  2. Substring matches (e.g., "cut" matches "ecutwfc") - medium priority
  3. Levenshtein distance for typos - lowest priority

This ensures semantic relevance: typing "relax" suggests "relax_method" instead of random 5-letter parameters like "nelec".

Parameters
queryThe parameter name to find similar matches for
max_suggestionsMaximum number of suggestions to return (default: 5)
max_distanceMaximum edit distance for fuzzy matches (default: 3)
Returns
Vector of similar parameter names sorted by relevance
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
osOutput stream to write YAML to (default: std::cout)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_metadata()

ParameterMetadata ModuleIO::ParameterHelp::get_metadata ( const std::string &  key)
static

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
keyThe 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. }

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
s1First string
s2Second string
Returns
Edit distance between the strings
Here is the caller graph for this function:

◆ 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
queryThe search query string
Returns
Vector of matching parameter names (sorted alphabetically)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
osOutput stream to write to (default: std::cout)
Here is the caller graph for this function:

◆ 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
keyThe parameter name to look up (case-insensitive)
osOutput stream to write to (default: std::cout)
Returns
true if parameter was found and help was displayed, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_lowercase()

std::string ModuleIO::ParameterHelp::to_lowercase ( const std::string &  str)
staticprivate

Convert string to lowercase for case-insensitive comparison.

Here is the caller graph for this function:

Member Data Documentation

◆ 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_

std::map< std::string, ParameterMetadata > ModuleIO::ParameterHelp::registry_
staticprivate

The documentation for this class was generated from the following files: