Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do a real distinction in between the code model and the view model #798

Open
tristanlatr opened this issue Jun 10, 2024 · 0 comments
Open

Comments

@tristanlatr
Copy link
Contributor

The view model would be initiated from a generated set of code models. The separation between the two models could firstly be done with Protocol classes (so we keep a unique structure at first) defining all required attributes by astbuilder and templatewriter. Classes that would be used to annotate Documentable to restrict the attributes that can be accessed.

Then we could look at creating two sets of concrete classes.

The main challenge of that operation (and probably the reason it has not been done a long time ago) is that the code model is strongly couple with the docstring parsing. Namely:

  • the parsing of @ivar-like fields which creates model instance with parsed_docstring attribute already populated.
  • the handling of property definitions which creates model instance with parsed_docstring attribute already populated.

The main goal being not perform docstring parsing until we have the final state for all objects. This issue might be solvable with an ast transformer. But I need to dig into that problematic a little bit - for instance we need to ensure that the line numbers are not altered by the transformation.

Once we really have this separation, we'll be abler to look at making our parser interchangeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant