-
Notifications
You must be signed in to change notification settings - Fork 36
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
feat: parse functions into objects #12
Conversation
hi @jakebrinkmann 😃 Thank you for your interest and contribution to the library. My original need was to document domain datastructures (dataclasses and namedtuples, mainly), but documenting domain logic seems also interesting (since it is your needs, someone else is likely to need it too). I think the issue is to find a way to represent a function entity in UML, which I think do not include functions in its modelling approach. In your example we would have liked to find the Maybe we could use the plantuml |
What about producing this kind of plantuml code for functions: http://www.plantuml.com/plantuml/uml/LOz1Iu1048NlyoiUT2bGy2Q8Y0Mj7Ie2woGU5XjbGMTZTpr4-DyRFGHT7lCUZ-ynRKmsf7rRYMNVOBp73m7zs_rBTQcQf_DMeGD4qsfZn8CDL--nw_eApowc8QOmqa54JXA7sKwC9J0d9mlg6hSckp6cB8lY3lCkKt9Uq3GNvKFK3BgTuTKBltz_yLXXzfw0FCzLTUzaQqM3Fovf_C-tB9_wooy0 I used the interface type, customized with an @startuml
enum Foo {
SPAM: SPAM
HAM: HAM
}
class Bar {
EGGS: List[str]
}
interface greeting << (F,#FF7700) function >> {
Union[Foo, NoneType]: foo
---
Bar
}
Foo -- greeting
Bar -- greeting
@enduml |
Oh Wow!! Your version is amazing! I love it! |
Only change I could say is possibly wanting to clearly differentiate between inputs and outputs somehow, possibly: |
slight changes:
What do you think?
|
hi @jakebrinkmann, how are you? I am wondering what the state of this PR is? Do you need any help? I refactored the code base in a pull request that was merged. I can help you resolving the conflicts with this PR, if you want. |
hi @jakebrinkmann , I have some suggestion about UML representation.
class Foo:
def __init__(self, bar: Bar):
self.bar = bar The type of relation may be aggregation. ( @startuml
Foo o-- Bar
@enduml
class Foo:
def __init__(self):
self.bar = Bar() The type of relation may be composition or aggregation. (When the object of Foo is deleted, self.bar deleted also) @startuml
Foo *-- Bar
@enduml
class Foo:
def func1(self):
self.func2(Bar()) # instantiated in `func1`
def func2(self, bar: Bar): # passed in `func2` as a parameter
bar.run() The type of relation is association. (It's temporary relations) @startuml
Foo ..> Bar
@enduml |
hi @doyou89 As far as I understand, @jakebrinkmann' s feature request is related to module functions (functions that take inputs and return outputs, detached from any class or instance), not to class or instance methods. The feature would include those functions alongside other data structures already handled by py2puml (classes, dataclasses, namedtuples, enums). However, your suggestions could be the basis to improvements of py2puml about the ways associations are drawn between datastructures. I am not a big fan of instantiating components inside the constructor (use case 2.) because it makes unit testing harder. |
What is the status of this PR? Do you need some help to finalize it? |
I am wondering if you want some help to rebase and merge this PR? |
I am interested in getting this done too. maybe we need to align these ideas with #11 too? |
Mostly looking for feedback/thoughts as I don't think this is quite ready for use as-is.
Here is some example Python-3.8 code:
which results in the following diagram:
My idea is to represent functions in such a way that the inputs/outputs are clear what class/datatype are being used in the functions. Again, not quite there yet, but motivated to explore this idea if anyone else is 😄
Perhaps the idea diverges too far from py2puml goals, but curious if this community had thoughts.
Thanks for reading!