Skip to content

Commit 6eaa903

Browse files
committed
Feat, plugin mode support comment handler
1 parent ac03ec7 commit 6eaa903

File tree

89 files changed

+788
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+788
-145
lines changed

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,24 @@ In addition to the configuration options in the example configuration file,
131131
the `protobuf-to-pydantic` plug-in also supports other configuration options.
132132
The specific configuration instructions are as follows:
133133

134-
| Configuration name | Functional module | Type | Hidden meaning |
135-
|-------------------------------|----------------------------------------|-------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
136-
| local_dict | Template | dict | Holds variables for the `local` template |
137-
| template | Template | protobuf_to_pydantic.template.Template | Implementation of the template class |
138-
| comment_prefix | Template | str | Comment prefix.Only strings with a fixed prefix will be used by the template |
139-
| parse_comment | comment(plugin only) | bool | If true, the annotation rule is compatible |
140-
| customer_import_set | Code generation | `Set[str]` | A collection of custom import statements, such as `from typing import Set`or `import typing`, that will write data in order to the source code file |
141-
| customer_deque | Code generation | `deque[str]` | Custom source file content, used to add custom content |
142-
| module_path | str | str | Used to define the root path of the project or module, which helps `protobuf-to-pydantic`to better automatically generate module import statements |
143-
| pyproject_file_path | Code generation | str | Define the pyproject file path, which defaults to the current project path |
144-
| code_indent | Code generation | int | Defines the number of indentation Spaces in the code; the default is 4 |
145-
| ignore_pkg_list | Code generation(plugin only) | `list[str]` | Definition ignores parsing of the specified package file |
146-
| base_model_class | Model Code generation, Code generation | `Type[BaseModel]` | Define the parent class of the generated Model |
147-
| file_name_suffix | Code generation | str | Define the generated file suffix, default `_p2p.py` |
148-
| file_descriptor_proto_to_code | Code generation(plugin only) | `Type[FileDescriptorProtoToCode]` | Define the `FileDescriptorProtoToCode` to use |
149-
| protobuf_type_config | Code generation(plugin only) | `Dict[str, ProtobufTypeConfigModel]` | Compatible with non-standard ones Message, See[ConfigModel note](https://github.com/so1n/protobuf_to_pydantic/blob/master/protobuf_to_pydantic/plugin/config.py) |
150-
| pkg_config |Code generation(plugin only)| `Dict[str, "ConfigModel"]` | Adapt the corresponding configuration for each PKG |
134+
| Configuration name | Functional module | Type | Hidden meaning |
135+
|-------------------------------|----------------------------------------|-------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
136+
| local_dict | Template | dict | Holds variables for the `local` template |
137+
| template | Template | protobuf_to_pydantic.template.Template | Implementation of the template class |
138+
| comment_prefix | Template | str | Comment prefix.Only strings with a fixed prefix will be used by the template |
139+
| parse_comment | comment(plugin only) | bool | If true, the annotation rule is compatible |
140+
| comment_handler| comment(plugin only) | Callable[[str, str, FieldInfo], FieldInfo] | Custom comment handler, Used to process parameter validation rules in comment, When using this configuration, the configuration parameters `comment_prefix` and `parse_comment` will not take effect, See[custom_comment_handler_pkg_plugin_config.py](https://github.com/so1n/protobuf_to_pydantic/blob/master/example/custom_comment_handler_pkg_plugin_config.py) |
141+
| customer_import_set | Code generation | `Set[str]` | A collection of custom import statements, such as `from typing import Set`or `import typing`, that will write data in order to the source code file |
142+
| customer_deque | Code generation | `deque[str]` | Custom source file content, used to add custom content |
143+
| module_path | str | str | Used to define the root path of the project or module, which helps `protobuf-to-pydantic`to better automatically generate module import statements |
144+
| pyproject_file_path | Code generation | str | Define the pyproject file path, which defaults to the current project path |
145+
| code_indent | Code generation | int | Defines the number of indentation Spaces in the code; the default is 4 |
146+
| ignore_pkg_list | Code generation(plugin only) | `list[str]` | Definition ignores parsing of the specified package file |
147+
| base_model_class | Model Code generation, Code generation | `Type[BaseModel]` | Define the parent class of the generated Model |
148+
| file_name_suffix | Code generation | str | Define the generated file suffix, default `_p2p.py` |
149+
| file_descriptor_proto_to_code | Code generation(plugin only) | `Type[FileDescriptorProtoToCode]` | Define the `FileDescriptorProtoToCode` to use |
150+
| protobuf_type_config | Code generation(plugin only) | `Dict[str, ProtobufTypeConfigModel]` | Compatible with non-standard ones Message, See[ConfigModel note](https://github.com/so1n/protobuf_to_pydantic/blob/master/protobuf_to_pydantic/plugin/config.py) |
151+
| pkg_config | Code generation(plugin only) | `Dict[str, "ConfigModel"]` | Adapt the corresponding configuration for each PKG |
151152

152153
> Note:
153154
> - 1:For more information, see the configuration instructions[/protobuf_to_pydantic/plugin/config.py](https://github.com/so1n/protobuf_to_pydantic/blob/master/protobuf_to_pydantic/plugin/config.py)

0 commit comments

Comments
 (0)