Skip to content

Commit bd462b4

Browse files
authored
Fix some minor formatting issue for the input-main.md (#6983)
* Fix formatting issue for input-main and update type info - Update the type field of parameter item field where multiple values are expected. - Fixed formatting issue in input-main.md where > and < are not escaped correctly. * Fix more formating issues Fixed some LaTeX issue and unify the description of types. * Add automatic escaping for < and > Escaping is performed when the md file is generated. * Minor wording updates
1 parent e69de94 commit bd462b4

12 files changed

+229
-119
lines changed

docs/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ You **must** regenerate `docs/parameters.yaml` whenever you:
173173
174174
### How to Regenerate
175175
176-
After building ABACUS, run:
176+
After building and installing ABACUS, run:
177177
178178
```bash
179-
./build/abacus --generate-parameters-yaml > docs/parameters.yaml
179+
abacus --generate-parameters-yaml > docs/parameters.yaml
180180
```
181181

182182
Then verify the YAML is valid:
@@ -191,7 +191,7 @@ You can also regenerate the markdown documentation locally:
191191
python3 docs/generate_input_main.py docs/parameters.yaml --output docs/advanced/input_files/input-main.md
192192
```
193193

194-
**Important:** Include the updated `docs/parameters.yaml` in your commit when submitting a PR that modifies INPUT parameters. Reviewers should verify the YAML changes match the C++ source changes.
194+
**Important:** Include the updated `docs/parameters.yaml` and `input-main.md` in your commit when submitting a PR that modifies INPUT parameters. Reviewers should verify the YAML changes match the C++ source changes and the `input-main.md` is updated.
195195

196196
### Parameter Documentation Format
197197

docs/advanced/input_files/input-main.md

Lines changed: 126 additions & 58 deletions
Large diffs are not rendered by default.

docs/generate_input_main.py

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""
1616

1717
import argparse
18+
import html
1819
import re
1920
import sys
2021
from pathlib import Path
@@ -69,6 +70,31 @@
6970
]
7071

7172

73+
def normalize_type(type_text: str) -> str:
74+
"""
75+
Normalize legacy type labels for cleaner generated docs.
76+
"""
77+
if not type_text:
78+
return ''
79+
80+
normalized = type_text.strip()
81+
aliases = {
82+
"Bool": "Boolean",
83+
"Int*2": "Integer*2",
84+
}
85+
return aliases.get(normalized, normalized)
86+
87+
88+
def escape_md_text(text: str) -> str:
89+
"""
90+
Escape markdown-sensitive angle brackets while avoiding double escaping.
91+
"""
92+
if text is None:
93+
return ''
94+
normalized = html.unescape(str(text))
95+
return normalized.replace('<', '&lt;').replace('>', '&gt;')
96+
97+
7298
def format_description(desc: str) -> str:
7399
"""
74100
Format description text for markdown output.
@@ -79,6 +105,10 @@ def format_description(desc: str) -> str:
79105
if not desc:
80106
return ''
81107

108+
# Prevent placeholder tokens like <property> from being parsed as raw HTML
109+
# and breaking list/heading structure in rendered docs.
110+
desc = escape_md_text(desc)
111+
82112
lines = desc.split('\n')
83113
result_lines = []
84114

@@ -94,6 +124,10 @@ def format_description(desc: str) -> str:
94124
if '[WARNING]' in line:
95125
line = line.replace('[WARNING]', '> Warning:')
96126

127+
# Normalize doubled note/warning prefixes from legacy content
128+
line = re.sub(r'>\s*Note:\s*Note\s*:?\s*', '> Note: ', line)
129+
line = re.sub(r'>\s*Warning:\s*Warning\s*:?\s*', '> Warning: ', line)
130+
97131
result_lines.append(line)
98132

99133
# Join and clean up
@@ -115,11 +149,13 @@ def generate_parameter_markdown(param: Dict[str, str]) -> str:
115149

116150
# Type
117151
if param.get('type', '') != '':
118-
lines.append(f"- **Type**: {param['type']}")
152+
type_text = escape_md_text(normalize_type(str(param['type'])))
153+
lines.append(f"- **Type**: {type_text}")
119154

120155
# Availability (before description, as in original format)
121156
if param.get('availability', '') != '':
122-
lines.append(f"- **Availability**: *{param['availability']}*")
157+
availability_text = escape_md_text(str(param['availability']))
158+
lines.append(f"- **Availability**: *{availability_text}*")
123159

124160
# Description
125161
if param.get('description', '') != '':
@@ -137,11 +173,13 @@ def generate_parameter_markdown(param: Dict[str, str]) -> str:
137173

138174
# Default
139175
if param.get('default_value', '') != '':
140-
lines.append(f"- **Default**: {param['default_value']}")
176+
default_text = escape_md_text(str(param['default_value']))
177+
lines.append(f"- **Default**: {default_text}")
141178

142179
# Unit
143180
if param.get('unit', '') != '':
144-
lines.append(f"- **Unit**: {param['unit']}")
181+
unit_text = escape_md_text(str(param['unit']))
182+
lines.append(f"- **Unit**: {unit_text}")
145183

146184
lines.append("")
147185
return '\n'.join(lines)
@@ -156,6 +194,10 @@ def generate_category_markdown(category: str, params: List[Dict[str, str]]) -> s
156194
for param in params:
157195
lines.append(generate_parameter_markdown(param))
158196

197+
# Keep legacy navigation aid used by downstream tooling/rendering.
198+
lines.append("[back to top](#full-list-of-input-keywords)")
199+
lines.append("")
200+
159201
return '\n'.join(lines)
160202

161203

docs/parameters.yaml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ parameters:
216216
availability: ""
217217
- name: kspacing
218218
category: System variables
219-
type: Real
219+
type: Vector of Real (1 or 3 values)
220220
description: |
221221
Set the smallest allowed spacing between k points, unit in 1/bohr. It should be larger than 0.0, and suggest smaller than 0.25. When you have set this value > 0.0, then the KPT file is unnecessary. The default value 0.0 means that ABACUS will read the applied KPT file.
222222
@@ -577,7 +577,7 @@ parameters:
577577
availability: ""
578578
- name: xc_exch_ext
579579
category: Electronic structure
580-
type: Integer Real ...
580+
type: Integer followed by Real values
581581
description: |
582582
Customized parameterization on the exchange part of XC functional. The first value should be the LibXC ID of the original functional, and latter values are external parameters. Default values are those of Perdew-Burke-Ernzerhof (PBE) functional. For more information on LibXC ID of functionals, please refer to LibXC. For parameters of functionals of interest, please refer to the source code of LibXC, such as PBE functional interface in LibXC: gga_x_pbe.c.
583583
@@ -587,7 +587,7 @@ parameters:
587587
availability: ""
588588
- name: xc_corr_ext
589589
category: Electronic structure
590-
type: Integer Real ...
590+
type: Integer followed by Real values
591591
description: |
592592
Customized parameterization on the correlation part of XC functional. The first value should be the LibXC ID of the original functional, and latter values are external parameters. Default values are those of Perdew-Burke-Ernzerhof (PBE) functional. For more information on LibXC ID of functionals, please refer to LibXC. For parameters of functionals of interest, please refer to the source code of LibXC, such as PBE functional interface in LibXC: gga_c_pbe.c.
593593
@@ -713,7 +713,7 @@ parameters:
713713
At n-th iteration which is calculated by drho<mixing_restart, SCF will start a mixing for real-space density matrix by using the same coefficiences as the mixing of charge density.
714714
default_value: "false"
715715
unit: ""
716-
availability: "Only for mixing_restart>=0.0"
716+
availability: "Only for mixing_restart >= 0.0"
717717
- name: mixing_gg0
718718
category: Electronic structure
719719
type: Real
@@ -1075,7 +1075,7 @@ parameters:
10751075
availability: ""
10761076
- name: bessel_nao_rcut
10771077
category: NAOs
1078-
type: Real
1078+
type: Vector of Real (N values)
10791079
description: |
10801080
Cutoff radius (in Bohr) and the common node of spherical Bessel functions used to construct the NAOs.
10811081
default_value: "6.0"
@@ -2316,7 +2316,7 @@ parameters:
23162316
availability: Numerical atomic orbital basis and deepks_scf is true
23172317
- name: deepks_band_range
23182318
category: DeePKS
2319-
type: "Int*2"
2319+
type: "Integer*2"
23202320
description: |
23212321
The first value should not be larger than the second one and the meaning differs in different cases below
23222322
* deepks_bandgap is 1: Bandgap label is the energy between LUMO + deepks_band_range[0] and LUMO + deepks_band_range[1]. If not set, it will calculate energy between HOMO and LUMO states.
@@ -2672,7 +2672,7 @@ parameters:
26722672
availability: ""
26732673
- name: lr_init_xc_kernel
26742674
category: Linear Response TDDFT (Under Development Feature)
2675-
type: String
2675+
type: "Vector of String (>=1 values)"
26762676
description: |
26772677
The method to initalize the xc kernel.
26782678
* "default": Calculate xc kernel from the ground-state charge density.
@@ -3477,7 +3477,7 @@ parameters:
34773477
availability: ""
34783478
- name: out_wannier_mmn
34793479
category: Berry phase and wannier90 interface
3480-
type: Bool
3480+
type: Boolean
34813481
description: |
34823482
Write the "*.mmn" file or not.
34833483
* 0: don't write the "*.mmn" file.
@@ -3487,7 +3487,7 @@ parameters:
34873487
availability: ""
34883488
- name: out_wannier_amn
34893489
category: Berry phase and wannier90 interface
3490-
type: Bool
3490+
type: Boolean
34913491
description: |
34923492
Write the "*.amn" file or not.
34933493
* 0: don't write the "*.amn" file.
@@ -3497,7 +3497,7 @@ parameters:
34973497
availability: ""
34983498
- name: out_wannier_eig
34993499
category: Berry phase and wannier90 interface
3500-
type: Bool
3500+
type: Boolean
35013501
description: |
35023502
Write the "*.eig" file or not.
35033503
* 0: don't write the "*.eig" file.
@@ -3507,7 +3507,7 @@ parameters:
35073507
availability: ""
35083508
- name: out_wannier_unk
35093509
category: Berry phase and wannier90 interface
3510-
type: Bool
3510+
type: Boolean
35113511
description: |
35123512
Write the "UNK.*" file or not.
35133513
* 0: don't write the "UNK.*" file.
@@ -3517,7 +3517,7 @@ parameters:
35173517
availability: ""
35183518
- name: out_wannier_wvfn_formatted
35193519
category: Berry phase and wannier90 interface
3520-
type: Bool
3520+
type: Boolean
35213521
description: |
35223522
Write the "UNK.*" file in ASCII format or binary format.
35233523
* 0: write the "UNK.*" file in binary format.
@@ -3840,25 +3840,25 @@ parameters:
38403840
availability: ""
38413841
- name: exx_fock_alpha
38423842
category: Exact Exchange (Common)
3843-
type: "Real \\Real...\\"
3843+
type: Real
38443844
description: |
3845-
Fraction of full-ranged Fock exchange 1/r () in range-separated hybrid funtionals, so that .
3845+
Fraction of full-ranged Fock exchange $1/r$ in range-separated hybrid functionals.
38463846
default_value: see hybrid_func_params
38473847
unit: ""
38483848
availability: ""
38493849
- name: exx_erfc_alpha
38503850
category: Exact Exchange (Common)
3851-
type: "Real \\Real...\\"
3851+
type: Real
38523852
description: |
3853-
Fraction of short-ranged Fock exchange erfc(wr)/r () in range-separated hybrid funtionals, so that .
3853+
Fraction of short-ranged Fock exchange $\mathrm{erfc}(\omega r)/r$ in range-separated hybrid functionals.
38543854
default_value: see hybrid_func_params
38553855
unit: ""
38563856
availability: ""
38573857
- name: exx_erfc_omega
38583858
category: Exact Exchange (Common)
3859-
type: "Real \\Real...\\"
3859+
type: Real
38603860
description: |
3861-
Range-separation parameter in exchange, such that
3861+
Range-separation parameter $\omega$ in the short-ranged Fock term $\mathrm{erfc}(\omega r)/r$.
38623862
default_value: see hybrid_func_params
38633863
unit: ""
38643864
availability: ""
@@ -3890,7 +3890,7 @@ parameters:
38903890
availability: exx_separate_loop==1
38913891
- name: exx_fock_lambda
38923892
category: Exact Exchange (LCAO in PW)
3893-
type: "Real \\Real...\\"
3893+
type: Real
38943894
description: |
38953895
It is used to compensate for divergence points at G=0 in the evaluation of Fock exchange using lcao_in_pw method.
38963896
default_value: "0.3"
@@ -4064,7 +4064,7 @@ parameters:
40644064
availability: basis_type==lcao
40654065
- name: orbital_corr
40664066
category: DFT+U correction
4067-
type: Integer
4067+
type: Vector of Integer (n values where n is the number of atomic types)
40684068
description: |
40694069
Specifies which orbits need plus U correction for each atom type ( for atom type 1, 2, 3, respectively).
40704070
* -1: The plus U correction will not be calculated for this atom.
@@ -4076,7 +4076,7 @@ parameters:
40764076
availability: ""
40774077
- name: hubbard_u
40784078
category: DFT+U correction
4079-
type: Real
4079+
type: Vector of Real (n values where n is the number of atomic types)
40804080
description: |
40814081
Specifies the Hubbard Coulomb interaction parameter U (eV) in plus U correction, which should be specified for each atom unless the Yukawa potential is used.
40824082
@@ -4119,16 +4119,16 @@ parameters:
41194119
* 1: The first SCF step will use an initial density matrix read from a file named initial_onsite.dm, but for later steps, the onsite density matrix will be updated.
41204120
* 2: The same onsite density matrix from initial_onsite.dm will be used throughout the entire calculation.
41214121
4122-
[NOTE] Note : The easiest way to create initial_onsite.dm is to run a DFT+U calculation, look for a file named onsite.dm in the OUT.prefix directory, and make replacements there. The format of the file is rather straight-forward.
4122+
[NOTE] The easiest way to create initial_onsite.dm is to run a DFT+U calculation, look for a file named onsite.dm in the OUT.prefix directory, and make replacements there. The format of the file is rather straight-forward.
41234123
default_value: "0"
41244124
unit: ""
41254125
availability: ""
41264126
- name: onsite_radius
41274127
category: DFT+U correction
41284128
type: Real
41294129
description: |
4130-
* The Onsite-radius parameter facilitates modulation of the single-zeta portion of numerical atomic orbitals for projections for DFT+U.
4131-
* The modulation algorithm includes a smooth truncation applied directly to the tail of the original orbital, followed by normalization. Consider the function: $\sigmar_c\sigmaf'(r)\equiv \mathrm{d}f(r)/\mathrm{d}r\gamma$ is a parameter that adjusts the relative weight of the error function to the derivative error function.
4130+
* The onsite_radius parameter facilitates modulation of the single-zeta portion of numerical atomic orbitals used for DFT+U projections.
4131+
* The modulation algorithm applies a smooth truncation to the orbital tail followed by normalization. A representative profile is $f(r)=\frac{1}{2}\left[1+\operatorname{erf}\!\left(\frac{r_c-r}{\sigma}\right)\right]$, where $r_c$ is the cutoff radius and $\sigma=\gamma r_c$ controls smoothness.
41324132
default_value: "3.0"
41334133
unit: Bohr
41344134
availability: dft_plus_u is set to 1
@@ -4233,15 +4233,15 @@ parameters:
42334233
availability: ""
42344234
- name: qo_strategy
42354235
category: Quasiatomic Orbital (QO) analysis
4236-
type: String
4236+
type: Vector of String (1 or n values where n is the number of atomic types)
42374237
description: |
42384238
Strategy to generate radial orbitals for QO analysis. For hydrogen: energy-valence, for pswfc and szv: all
42394239
default_value: "for hydrogen: energy-valence, for pswfc and szv: all"
42404240
unit: ""
42414241
availability: ""
42424242
- name: qo_screening_coeff
42434243
category: Quasiatomic Orbital (QO) analysis
4244-
type: Real
4244+
type: Vector of Real (n values where n is the number of atomic types; 1 value allowed for qo_basis=pswfc)
42454245
description: |
42464246
The screening coefficient for each atom type to rescale the shape of radial orbitals
42474247
default_value: "0.1"

source/source_io/module_parameter/read_input_item_deepks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ void ReadInput::item_deepks()
247247
Input_Item item("deepks_band_range");
248248
item.annotation = "(int, int) range of bands for bandgap label";
249249
item.category = "DeePKS";
250-
item.type = "Int*2";
250+
item.type = "Integer*2";
251251
item.description = R"(The first value should not be larger than the second one and the meaning differs in different cases below
252252
* deepks_bandgap is 1: Bandgap label is the energy between LUMO + deepks_band_range[0] and LUMO + deepks_band_range[1]. If not set, it will calculate energy between HOMO and LUMO states.
253253
* deepks_bandgap is 2: Bandgap labels are energies between HOMO and all states in range [LUMO + deepks_band_range[0], LUMO + deepks_band_range[1]] (Thus there are deepks_band_range[1] - deepks_band_range[0] + 1 bandgaps in total). If HOMO is included in the setting range, it will be ignored since it will always be zero and has no valuable messages (deepks_band_range[1] - deepks_band_range[0] bandgaps in this case). NOTICE: The set range can be greater than, less than, or include the value of HOMO. In the bandgap label, we always calculate the energy of the state in the set range minus the energy of HOMO state, so the bandgap can be negative if the state is lower than HOMO.)";

source/source_io/module_parameter/read_input_item_elec_stru.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ The other way is only available when compiling with LIBXC, and it allows for sup
350350
Input_Item item("xc_exch_ext");
351351
item.annotation = "placeholder for xcpnet exchange functional";
352352
item.category = "Electronic structure";
353-
item.type = "Integer Real ...";
353+
item.type = "Integer followed by Real values";
354354
item.description = "Customized parameterization on the exchange part of XC functional. The first value should be the LibXC ID of the original functional, and latter values are external parameters. Default values are those of Perdew-Burke-Ernzerhof (PBE) functional. For more information on LibXC ID of functionals, please refer to LibXC. For parameters of functionals of interest, please refer to the source code of LibXC, such as PBE functional interface in LibXC: gga_x_pbe.c."
355355
"\n\n[NOTE] Solely setting this keyword will take no effect on XC functionals. One should also set "
356356
"dft_functional to the corresponding functional to apply the customized parameterization. "
@@ -393,7 +393,7 @@ The other way is only available when compiling with LIBXC, and it allows for sup
393393
Input_Item item("xc_corr_ext");
394394
item.annotation = "placeholder for xcpnet exchange functional";
395395
item.category = "Electronic structure";
396-
item.type = "Integer Real ...";
396+
item.type = "Integer followed by Real values";
397397
item.description = "Customized parameterization on the correlation part of XC functional. The first value should be the LibXC ID of the original functional, and latter values are external parameters. Default values are those of Perdew-Burke-Ernzerhof (PBE) functional. For more information on LibXC ID of functionals, please refer to LibXC. For parameters of functionals of interest, please refer to the source code of LibXC, such as PBE functional interface in LibXC: gga_c_pbe.c."
398398
"\n\n[NOTE] Solely setting this keyword will take no effect on XC functionals. One should also set "
399399
"dft_functional to the corresponding functional to apply the customized parameterization. "
@@ -675,7 +675,7 @@ For systems that are difficult to converge, one could try increasing the value o
675675
item.description = "At n-th iteration which is calculated by drho<mixing_restart, SCF will start a mixing for real-space density matrix by using the same coefficiences as the mixing of charge density.";
676676
item.default_value = "false";
677677
item.unit = "";
678-
item.availability = "Only for mixing_restart>=0.0";
678+
item.availability = "Only for mixing_restart >= 0.0";
679679
read_sync_bool(input.mixing_dmr);
680680
this->add_item(item);
681681
}
@@ -1350,7 +1350,7 @@ Use case: When experimental or high-level theoretical results suggest that the S
13501350
Input_Item item("bessel_nao_rcut");
13511351
item.annotation = "radial cutoff for spherical bessel functions(a.u.)";
13521352
item.category = "NAOs";
1353-
item.type = "Real";
1353+
item.type = "Vector of Real (N values)";
13541354
item.description = "Cutoff radius (in Bohr) and the common node of spherical Bessel functions used to construct the NAOs.";
13551355
item.default_value = "6.0";
13561356
item.unit = "";

0 commit comments

Comments
 (0)