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

1119 specify method return type in class diagram #1178

Merged

Conversation

jgreywolf
Copy link
Contributor

@jgreywolf jgreywolf commented Jan 6, 2020

📑 Summary

Updated ClassRenderer to check for [] to indicate return type for method. Small refactor to split out logic for determining method display text and style. Updated documentation

Resolves #1119

📏 Design Decisions

Still using existence of ) to determine if member is a method, but using regex to parse out method text into discrete elements (visibility, method name, parameters, classifier and return type)

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added unit/e2e tests (if appropriate)
  • 🔖 targeted develop branch

@klemmchr klemmchr requested a review from knsv January 6, 2020 19:22
@klemmchr
Copy link
Member

klemmchr commented Jan 6, 2020

I don't know if the bracket syntax is really helping to keep the syntax plain. I think I would prefer to write a normal UML syntax and have a regex classify whether this member is a field or a method. If we use brackets, we could end up with broken diagrams.

@jgreywolf
Copy link
Contributor Author

jgreywolf commented Jan 6, 2020

I don't know if the bracket syntax is really helping to keep the syntax plain. I think I would prefer to write a normal UML syntax and have a regex classify whether this member is a field or a method. If we use brackets, we could end up with broken diagrams.

I suppose if we just stick with a regular UML syntax, then really we dont need to do anything at all, yes? As long as the user understands this and defines their methods accordingly. Explicitly add : RETURNTYPE to the end of their method statement (or some other format), since we just display whatever is typed in at that point...

Or to go with regex, we could just have it that the pattern is like:

[**VISIBILITY**]methodName([**PARAMETER**])[**CLARIFIER**] [**RETURNTYPE**]

which would display as something like: +methodName(int id) : int(assuming [CLARIFIER] set to static)

@jgreywolf
Copy link
Contributor Author

After some consideration and playing around, I decided to go ahead and go with the idea of parsing out the text via regex. If for some reason the regex match function fails it will "fallback" to existing functionality of displaying the method as it was typed in.

jgreywolf and others added 6 commits January 10, 2020 09:47
Updated ClassRenderer to check for `[]` to indicate return type for method. Small refactor to split out logic for determining method display text and style. Updated documentation
Small refactor to split out logic for determining method display text and style. Updated documentation
Used regex to parse method statements in class diagrams to extract discrete elements to set display appropriately. Added tests and updated docs
@jgreywolf jgreywolf force-pushed the 1119-SpecifyMethodReturnTypeInClassDiagram branch from 030c5a3 to fa1331f Compare January 10, 2020 18:25
@jgreywolf
Copy link
Contributor Author

Force pushed new version due to some oddities in merge from develop.

@knsv knsv merged commit eade3d0 into mermaid-js:develop Jan 13, 2020
@jgreywolf jgreywolf deleted the 1119-SpecifyMethodReturnTypeInClassDiagram branch January 13, 2020 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Class diagram specify return type
3 participants