Merge pull request #1039 from lf-novelt/master

Support for underscore in classDiagrams class names
This commit is contained in:
ashishjain0512
2019-10-30 19:01:11 +01:00
committed by GitHub
4 changed files with 14 additions and 11 deletions

View File

@@ -44,7 +44,7 @@ Mermaid can render class diagrams.
+String beakColor +String beakColor
+swim() +swim()
+quack() +quack()
} }
class Fish{ class Fish{
-int sizeInFeet -int sizeInFeet
-canEat() -canEat()
@@ -69,7 +69,7 @@ A single instance of a class in the diagram contains three compartments:
``` ```
classDiagram classDiagram
class BankAccount class BankAccount
BankAccount : +String onwer BankAccount : +String owner
BankAccount : +Bigdecimal balance BankAccount : +Bigdecimal balance
BankAccount : +deposit(amount) BankAccount : +deposit(amount)
BankAccount : +withdrawl(amount) BankAccount : +withdrawl(amount)
@@ -77,7 +77,7 @@ classDiagram
```mermaid ```mermaid
classDiagram classDiagram
class BankAccount class BankAccount
BankAccount : +String onwer BankAccount : +String owner
BankAccount : +BigDecimal balance BankAccount : +BigDecimal balance
BankAccount : +deposit(amount) BankAccount : +deposit(amount)
BankAccount : +withdrawl(amount) BankAccount : +withdrawl(amount)
@@ -98,6 +98,9 @@ classDiagram
class Animal class Animal
Vehicle <|-- Car Vehicle <|-- Car
``` ```
Naming convention: a class name should be composed of alphanumeric (unicode allowed) and underscore characters.
## Defining Members of a class ## Defining Members of a class
UML provides mechanisms to represent class members, such as attributes and methods, and additional information about them. UML provides mechanisms to represent class members, such as attributes and methods, and additional information about them.
@@ -117,7 +120,7 @@ There are two ways to define the members of a class, and regardless of the which
``` ```
class BankAccount class BankAccount
BankAccount : +String onwer BankAccount : +String owner
BankAccount : +BigDecimal balance BankAccount : +BigDecimal balance
BankAccount : +deposit(amount) BankAccount : +deposit(amount)
BankAccount : +withdrawl(amount) BankAccount : +withdrawl(amount)
@@ -125,7 +128,7 @@ There are two ways to define the members of a class, and regardless of the which
```mermaid ```mermaid
classDiagram classDiagram
class BankAccount class BankAccount
BankAccount : +String onwer BankAccount : +String owner
BankAccount : +BigDecimal balance BankAccount : +BigDecimal balance
BankAccount : +deposit(amount) BankAccount : +deposit(amount)
BankAccount : +withdrawl(amount) BankAccount : +withdrawl(amount)
@@ -134,7 +137,7 @@ There are two ways to define the members of a class, and regardless of the which
- Associate members of a class using **{}** brackets, where members are grouped within curly brackets. Suitable for defining multiple members at once. For example: - Associate members of a class using **{}** brackets, where members are grouped within curly brackets. Suitable for defining multiple members at once. For example:
``` ```
class BankAccount{ class BankAccount{
+String onwer +String owner
+BigDecimal balance +BigDecimal balance
+deposit(amount) +deposit(amount)
+withdrawl(amount) +withdrawl(amount)
@@ -143,7 +146,7 @@ class BankAccount{
```mermaid ```mermaid
classDiagram classDiagram
class BankAccount{ class BankAccount{
+String onwer +String owner
+BigDecimal balance +BigDecimal balance
+deposit(amount) +deposit(amount)
+withdrawl(amount) +withdrawl(amount)

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "mermaid", "name": "mermaid",
"version": "8.3.1", "version": "8.4.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@@ -64,7 +64,7 @@ describe('class diagram, ', function() {
it('should handle parsing of method statements grouped by brackets', function() { it('should handle parsing of method statements grouped by brackets', function() {
const str = const str =
'classDiagram\n' + 'classDiagram\n' +
'class Dummy {\n' + 'class Dummy_Class {\n' +
'String data\n' + 'String data\n' +
' void methods()\n' + ' void methods()\n' +
'}\n' + '}\n' +

View File

@@ -43,8 +43,8 @@
\% return 'PCT'; \% return 'PCT';
"=" return 'EQUALS'; "=" return 'EQUALS';
\= return 'EQUALS'; \= return 'EQUALS';
[A-Za-z]+ return 'ALPHA'; \w+ return 'ALPHA';
[!"#$%&'*+,-.`?\\_/] return 'PUNCTUATION'; [!"#$%&'*+,-.`?\\/] return 'PUNCTUATION';
[0-9]+ return 'NUM'; [0-9]+ return 'NUM';
[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]| [\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|
[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]| [\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|