|
| 1 | +Configuration Files |
| 2 | +=================== |
| 3 | + |
| 4 | +PyConverter-XML2Py uses configuration files to customize the conversion process. |
| 5 | +The main configuration is stored in ``config.yaml``. |
| 6 | + |
| 7 | +config.yaml Structure |
| 8 | +--------------------- |
| 9 | + |
| 10 | +The ``config.yaml`` file controls various aspects of the package generation process: |
| 11 | + |
| 12 | +.. code:: yaml |
| 13 | +
|
| 14 | + # Package metadata |
| 15 | + new_package_name: "package" |
| 16 | + project_name: "MyProject" |
| 17 | + |
| 18 | + # Directory structure |
| 19 | + library_name_structured: ["src", "myproject"] |
| 20 | + subfolders: ["subfolder1", "subfolder2"] |
| 21 | + image_folder_path: "images" |
| 22 | +
|
| 23 | + # Command processing |
| 24 | + rules: |
| 25 | + "/": slash |
| 26 | + "*": star |
| 27 | +
|
| 28 | + ignored_commands: |
| 29 | + - "COMMAND1" |
| 30 | + - "COMMAND2" |
| 31 | + |
| 32 | + specific_command_mapping: |
| 33 | + "OLD_NAME": "new_name" |
| 34 | + |
| 35 | + specific_classes: |
| 36 | + "OldClassName": "NewClassName" |
| 37 | + |
| 38 | + # Custom comments for commands |
| 39 | + comments: |
| 40 | + - msg: "Custom comment text" |
| 41 | + type: "warning" |
| 42 | + command: ["COMMAND3", "COMMAND4"] |
| 43 | + - msg: "Another comment" |
| 44 | + type: "note" |
| 45 | + command: ["COMMAND5"] |
| 46 | + |
| 47 | +
|
| 48 | +Configuration Options |
| 49 | +--------------------- |
| 50 | + |
| 51 | +Package Metadata |
| 52 | +^^^^^^^^^^^^^^^^^ |
| 53 | + |
| 54 | +.. option:: new_package_name |
| 55 | + |
| 56 | + The name of the generated package directory. |
| 57 | + |
| 58 | + **Default:** ``"package"`` |
| 59 | + |
| 60 | +.. option:: project_name |
| 61 | + |
| 62 | + The display name of the project used in documentation. |
| 63 | + |
| 64 | +Directory Structure |
| 65 | +^^^^^^^^^^^^^^^^^^^ |
| 66 | + |
| 67 | +.. option:: library_name |
| 68 | + |
| 69 | + List defining the nested directory structure for the generated Python modules. |
| 70 | + |
| 71 | + **Example:** ``["src", "myproject"]`` creates ``src/myproject/`` structure |
| 72 | + |
| 73 | +.. option:: subfolders |
| 74 | + |
| 75 | + List of subfolders where to place the converted files within the package. |
| 76 | + |
| 77 | + **Example:** ``["subfolder1", "subfolder2"]`` creates additional directories under the package. |
| 78 | + |
| 79 | +.. option:: image_folder_path |
| 80 | + |
| 81 | + Relative path where images from the XML documentation will be added. |
| 82 | + |
| 83 | + **Default:** ``"images"`` |
| 84 | + |
| 85 | +Command Processing |
| 86 | +^^^^^^^^^^^^^^^^^^ |
| 87 | + |
| 88 | +.. option:: rules |
| 89 | + |
| 90 | + Dictionary defining how to handle specific commands or patterns during conversion. |
| 91 | + |
| 92 | + **Example:** ``{"/": "slash", "*": "star"}`` maps commands starting with `/` to `slash` and `*` to `star`. |
| 93 | + |
| 94 | +.. option:: ignored_commands |
| 95 | + |
| 96 | + List of command names to skip during conversion. |
| 97 | + |
| 98 | + **Type:** List of strings |
| 99 | + |
| 100 | +.. option:: specific_command_mapping |
| 101 | + |
| 102 | + Dictionary mapping original command names to custom Python function names. |
| 103 | + |
| 104 | + **Example:** ``{"/CLEAR": "clear_all", "*GET": "get_parameter"}`` |
| 105 | + |
| 106 | +.. option:: specific_classes |
| 107 | + |
| 108 | + Dictionary mapping original class names to custom class names. |
| 109 | + |
| 110 | + **Example:** ``{"Mesh Controls": "Meshing Controls", "Solver Settings": "Solution Settings"}`` |
| 111 | + |
| 112 | +Custom comments |
| 113 | +^^^^^^^^^^^^^^^ |
| 114 | + |
| 115 | +.. option:: comments |
| 116 | + |
| 117 | + Custom comments for specific commands. |
| 118 | + |
| 119 | + **Type:** List of dictionaries with keys `msg`, `type`, and `command`. |
| 120 | + |
| 121 | + |
| 122 | +Template Configuration |
| 123 | +---------------------- |
| 124 | + |
| 125 | +When using custom templates, you can override the default template structure |
| 126 | +by providing a ``template_path`` to the CLI or by placing a custom template |
| 127 | +in the ``_package`` directory. |
| 128 | + |
| 129 | +The template directory should contain: |
| 130 | + |
| 131 | +.. code:: text |
| 132 | +
|
| 133 | + _package/ |
| 134 | + ├── pyproject.toml |
| 135 | + ├── README.rst |
| 136 | + ├── LICENSE |
| 137 | + ├── AUTHORS.md |
| 138 | + ├── pre-commit-config.yaml |
| 139 | + └── doc/ |
| 140 | + ├── Makefile |
| 141 | + ├── make.bat |
| 142 | + ├── .vale.ini |
| 143 | + ├── source/ |
| 144 | + │ ├── conf.py |
| 145 | + │ ├── index.rst |
| 146 | + │ └── _templates/ # if needed |
| 147 | + └── styles/ |
| 148 | + └── .gitignore |
| 149 | + └── Vocab/ |
| 150 | +
|
| 151 | +Custom Function Configuration |
| 152 | +----------------------------- |
| 153 | + |
| 154 | +For information about configuring custom functions, see :doc:`customized_functions`. |
| 155 | + |
| 156 | +Example Configuration |
| 157 | +--------------------- |
| 158 | + |
| 159 | +Here's a complete example ``config.yaml``: |
| 160 | + |
| 161 | +.. code:: yaml |
| 162 | +
|
| 163 | + new_package_name: "my_generated_package" |
| 164 | + project_name: "My ANSYS Package" |
| 165 | + |
| 166 | + library_name_structured: ["src", "ansys", "mypackage"] |
| 167 | + subfolders: ["utilities", "data_processing"] |
| 168 | + image_folder_path: "../images" |
| 169 | + |
| 170 | + rules: |
| 171 | + "/": "slash" |
| 172 | + "*": "star" |
| 173 | +
|
| 174 | + ignored_commands: |
| 175 | + - "OBSOLETE_CMD" |
| 176 | + - "DEPRECATED_FUNC" |
| 177 | + |
| 178 | + specific_command_mapping: |
| 179 | + "/CLEAR": "clear_all" |
| 180 | + "*GET": "get_parameter" |
| 181 | + |
| 182 | + specific_classes: |
| 183 | + "MeshControls": "MeshingControls" |
| 184 | + "SolverSettings": "SolutionSettings" |
| 185 | + |
| 186 | + comments: |
| 187 | + - msg: "This command is deprecated, use 'new_command' instead." |
| 188 | + type: "warning" |
| 189 | + command: ["OLD_COMMAND"] |
0 commit comments