Fix documentation
Summary
The documentation of services and methods was not properly added to the generated files. The issue was that ServiceCompiler and ServiceMethodCompiler didn't have access to the value of source_file, unlike the other compilers.
As far as I understand, the field was accessed in the get_comment function. Since it was missing, an AttributeError was raised, but this error was catched by jinja automatically, as in the following example:
from dataclasses import dataclass
from jinja2 import Template
TEMPLATE: str = """
AA
{{ my_class.field }}
BB
{{ my_class.nothing }}
CC
"""
@dataclass
class MyClass:
field: int
print(Template(TEMPLATE).render(my_class=MyClass(field=42)))
Checklist
- [X] If code changes were made then they have been tested.
- [X] This PR fixes an issue.
To avoid silencing these errors, it is possible to add a parameter undefined=jinja2.StrictUndefined to the jinja2 environment. I didn't add it here since other errors are currently raised, but I think it would be a good thing to do it at some point. Maybe some issues are still hidden by this behavior.
Thanks!