AutoCorrect2 writer¶
writer ¶
Append approved AutoCorrect2 candidates to the generated include file.
GENERATED_FILE_HEADER
module-attribute
¶
GENERATED_FILE_HEADER = "; AUTO-GENERATED BY autocorrect2-hotstring-generation\n; Add this file to AutoCorrect2 with a one-time #Include.\n; Do not edit generated entries manually.\n"
Header written when the generated include file is first created.
append_candidates ¶
append_candidates(
candidates: Sequence[AutoCorrect2CandidateHotstring],
*,
project_dir: Path,
relative_path: Path = GENERATED_HOTSTRINGS_RELATIVE_PATH,
) -> Path
Append accepted candidates to the project-owned AutoCorrect2 include.
Each candidate must explicitly use B0 and X, which are required by the
AutoCorrect2 f()-based generated form. Trigger rendering is delegated to
the hotstring model, which emits its canonical ahk_trigger source form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidates
|
Sequence[AutoCorrect2CandidateHotstring]
|
Accepted AutoCorrect2 candidates to append. |
required |
project_dir
|
Path
|
AutoCorrect2 project directory. |
required |
relative_path
|
Path
|
Generated include path relative to |
GENERATED_HOTSTRINGS_RELATIVE_PATH
|
Returns:
| Type | Description |
|---|---|
Path
|
Path of the generated include file. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a candidate is not explicitly configured with |
OSError
|
If the generated file cannot be read or written. |
Source code in hotstring\autocorrect2\writer.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
_validate_writable_candidate ¶
_validate_writable_candidate(
candidate: AutoCorrect2CandidateHotstring,
) -> None
Validate the AutoCorrect2-specific B0X writing contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidate
|
AutoCorrect2CandidateHotstring
|
Candidate that may be appended to the generated include. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If automatic backspacing is not explicitly disabled or execution is not explicitly enabled. |
Source code in hotstring\autocorrect2\writer.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |