Fix documentation (#630)
* Fix missing documentation * Add test * Add test * Format * Reformat
This commit is contained in:
20
tests/inputs/documentation/documentation.proto
Normal file
20
tests/inputs/documentation/documentation.proto
Normal file
@@ -0,0 +1,20 @@
|
||||
syntax = "proto3";
|
||||
package documentation;
|
||||
|
||||
// Documentation of message
|
||||
message Test {
|
||||
// Documentation of field
|
||||
uint32 x = 1;
|
||||
}
|
||||
|
||||
// Documentation of enum
|
||||
enum Enum {
|
||||
// Documentation of variant
|
||||
Enum_Variant = 0;
|
||||
}
|
||||
|
||||
// Documentation of service
|
||||
service Service {
|
||||
// Documentation of method
|
||||
rpc get(Test) returns (Test);
|
||||
}
|
29
tests/test_documentation.py
Normal file
29
tests/test_documentation.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import ast
|
||||
import inspect
|
||||
|
||||
|
||||
def test_documentation():
|
||||
from .output_betterproto.documentation import (
|
||||
Enum,
|
||||
ServiceBase,
|
||||
ServiceStub,
|
||||
Test,
|
||||
)
|
||||
|
||||
assert Test.__doc__ == "Documentation of message"
|
||||
|
||||
source = inspect.getsource(Test)
|
||||
tree = ast.parse(source)
|
||||
assert tree.body[0].body[2].value.value == "Documentation of field"
|
||||
|
||||
assert Enum.__doc__ == "Documentation of enum"
|
||||
|
||||
source = inspect.getsource(Enum)
|
||||
tree = ast.parse(source)
|
||||
assert tree.body[0].body[2].value.value == "Documentation of variant"
|
||||
|
||||
assert ServiceBase.__doc__ == "Documentation of service"
|
||||
assert ServiceBase.get.__doc__ == "Documentation of method"
|
||||
|
||||
assert ServiceStub.__doc__ == "Documentation of service"
|
||||
assert ServiceStub.get.__doc__ == "Documentation of method"
|
Reference in New Issue
Block a user