Update readme with new output structure and fix example inconsistencies
This commit is contained in:
		
							
								
								
									
										25
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								README.md
									
									
									
									
									
								
							| @@ -68,14 +68,15 @@ message Greeting { | |||||||
| You can run the following: | You can run the following: | ||||||
|  |  | ||||||
| ```sh | ```sh | ||||||
| $ protoc -I . --python_betterproto_out=. example.proto | $ mkdir lib | ||||||
|  | $ protoc -I . --python_betterproto_out=lib example.proto | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| This will generate `hello.py` which looks like: | This will generate `lib/hello/__init__.py` which looks like: | ||||||
|  |  | ||||||
| ```py | ```python | ||||||
| # Generated by the protocol buffer compiler.  DO NOT EDIT! | # Generated by the protocol buffer compiler.  DO NOT EDIT! | ||||||
| # sources: hello.proto | # sources: example.proto | ||||||
| # plugin: python-betterproto | # plugin: python-betterproto | ||||||
| from dataclasses import dataclass | from dataclasses import dataclass | ||||||
|  |  | ||||||
| @@ -83,7 +84,7 @@ import betterproto | |||||||
|  |  | ||||||
|  |  | ||||||
| @dataclass | @dataclass | ||||||
| class Hello(betterproto.Message): | class Greeting(betterproto.Message): | ||||||
|     """Greeting represents a message you can tell a user.""" |     """Greeting represents a message you can tell a user.""" | ||||||
|  |  | ||||||
|     message: str = betterproto.string_field(1) |     message: str = betterproto.string_field(1) | ||||||
| @@ -91,23 +92,23 @@ class Hello(betterproto.Message): | |||||||
|  |  | ||||||
| Now you can use it! | Now you can use it! | ||||||
|  |  | ||||||
| ```py | ```python | ||||||
| >>> from hello import Hello | >>> from lib.hello import Greeting | ||||||
| >>> test = Hello() | >>> test = Greeting() | ||||||
| >>> test | >>> test | ||||||
| Hello(message='') | Greeting(message='') | ||||||
|  |  | ||||||
| >>> test.message = "Hey!" | >>> test.message = "Hey!" | ||||||
| >>> test | >>> test | ||||||
| Hello(message="Hey!") | Greeting(message="Hey!") | ||||||
|  |  | ||||||
| >>> serialized = bytes(test) | >>> serialized = bytes(test) | ||||||
| >>> serialized | >>> serialized | ||||||
| b'\n\x04Hey!' | b'\n\x04Hey!' | ||||||
|  |  | ||||||
| >>> another = Hello().parse(serialized) | >>> another = Greeting().parse(serialized) | ||||||
| >>> another | >>> another | ||||||
| Hello(message="Hey!") | Greeting(message="Hey!") | ||||||
|  |  | ||||||
| >>> another.to_dict() | >>> another.to_dict() | ||||||
| {"message": "Hey!"} | {"message": "Hey!"} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user