diff --git a/Dockerfile b/Dockerfile index e517f8076ac997189538216a35389042f584df40..7ebb3942371bb362a12f4c04b18cebbcd166eec9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,7 @@ FROM texlive/texlive RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get -y upgrade && apt-get -y install inkscape plantuml openjdk-11-jdk-headless hunspell hunspell-hu hunspell-en-gb hunspell-en-us python3-pip && pip3 install javalang COPY tikz-uml.sty /usr/local/texlive/2020/texmf-dist/tex/latex/tikz-uml/tikz-uml.sty -COPY jsonDoclet.jar /root/jsonDoclet.jar -COPY ./plab/out/plab /usr/bin/plab RUN mktexlsr COPY gen_seq_diag.py / -RUN chmod +x /gen_seq_diag.py \ No newline at end of file +COPY jsonDoclet.jar /root/jsonDoclet.jar +COPY ./plab/out/plab /usr/bin/plab diff --git a/plab/classdiag.go b/plab/classdiag.go index 19720c790a26bbff775e03ae1e34a663ac0dee08..c1f600341c5b91a653ad35d5d4c19d4b840d6c1a 100644 --- a/plab/classdiag.go +++ b/plab/classdiag.go @@ -2,7 +2,6 @@ package main import ( "bytes" - "encoding/json" "fmt" "io/ioutil" "os" @@ -80,12 +79,14 @@ func genPlantUMLStr(classes map[string]*Class) { for _, e := range a.Elements { switch e.QualifiedName { case "projlab.Docs.uml": - e.Value = strings.ReplaceAll(e.Value, "\\\"", "🍆") - e.Value = strings.ReplaceAll(e.Value, "\"", "") - e.Value = strings.ReplaceAll(e.Value, "🍆", "\"") + e.Value = unescape(e.Value) uml = true + t := f.Type.Name + if strings.Contains(t, "..") { + t = strings.Split(t, " ")[0] + } if e.Value != "" { - after += fmt.Sprintf("\n%s %s %s", f.Type.Name, e.Value, c.Name) + after += fmt.Sprintf("\n%s %s %s", t, e.Value, c.Name) } } } @@ -118,9 +119,7 @@ func genPlantUMLStr(classes map[string]*Class) { for _, e := range a.Elements { switch e.QualifiedName { case "projlab.Docs.uml": - e.Value = strings.ReplaceAll(e.Value, "\\\"", "🍆") - e.Value = strings.ReplaceAll(e.Value, "\"", "") - e.Value = strings.ReplaceAll(e.Value, "🍆", "\"") + e.Value = unescape(e.Value) output.WriteString(fmt.Sprintln(e.Value)) } } @@ -144,16 +143,31 @@ func genPlantUMLStr(classes map[string]*Class) { } for _, c := range classes { - out, e := json.Marshal(*c) - if e != nil { - panic(e) + deps := make([]string, 0) + hasdep := func(dep string) bool { + for _, d := range deps { + if d == dep { + return true + } + } + return false } - str := string(out) + + for _, dep := range c.Fields { + deps = append(deps, dep.Type.Name) + } + for _, dep := range c.Methods { + deps = append(deps, dep.ReturnType.Name) + for _, d := range dep.Parameters { + deps = append(deps, d.Type.Name) + } + } + for _, c2 := range classes { if c2.Name == c.Name { continue } - if strings.Contains(str, c2.Name) { + if hasdep(c2.Name) { skips := skip[c2.Name] shouldSkip := false for _, s := range skips { diff --git a/plab/javadoc.go b/plab/javadoc.go index 1c02f09ca386469364c2bc93a61652f4e48098b8..8ffc7478fbb5fff05af5fe70dc84345014660dde 100644 --- a/plab/javadoc.go +++ b/plab/javadoc.go @@ -204,7 +204,7 @@ func readJson(fname string) (*Class, error) { for _, e := range a.Elements { switch e.QualifiedName { case "projlab.Docs.type": - e.Value = strings.ReplaceAll(e.Value, "\"", "") + e.Value = unescape(e.Value) if e.Value != "" { replace(arr[i], e.Value) } diff --git a/plab/unescape.go b/plab/unescape.go new file mode 100644 index 0000000000000000000000000000000000000000..616e103b569df643ebcdc033602dd9177616865b --- /dev/null +++ b/plab/unescape.go @@ -0,0 +1,9 @@ +package main + +import "encoding/json" + +func unescape(s string) string { + var ret string + _ = json.Unmarshal([]byte(s), &ret) + return ret +}