From 85cc78fef2d0770d0b5a40ebfccf95426599f8b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20T=C3=B3th?= <tothmiklostibor@gmail.com> Date: Sat, 27 Feb 2021 19:02:13 +0100 Subject: [PATCH] add stuff --- Dockerfile | 5 +-- Makefile | 4 +-- plab/.gitignore | 3 +- plab/Makefile | 5 ++- plab/javadoc.go | 84 +++++++++++++++++++++++++++++++++++-------------- 5 files changed, 70 insertions(+), 31 deletions(-) diff --git a/Dockerfile b/Dockerfile index d132c55..d46329e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM texlive/texlive -RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get -y upgrade && apt-get -y install openjdk-11-jdk-headless hunspell-hu hunspell-en-gb hunspell-en-us +RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get -y upgrade && apt-get -y install openjdk-11-jdk-headless hunspell hunspell-hu hunspell-en-gb hunspell-en-us 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 +COPY ./plab/out/plab /usr/bin/plab +ADD robinbird/build/distributions/robinbird.tar / RUN mktexlsr diff --git a/Makefile b/Makefile index 967031e..f8f2279 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,4 @@ all: docker docker: - docker build -t projlab . - docker tag projlab projlab/projlab - docker push projlab/projlab \ No newline at end of file + docker build -t projlab/projlab . diff --git a/plab/.gitignore b/plab/.gitignore index 55b3bcd..f3a9241 100644 --- a/plab/.gitignore +++ b/plab/.gitignore @@ -1,3 +1,4 @@ plab test.yml -tmp \ No newline at end of file +tmp +out \ No newline at end of file diff --git a/plab/Makefile b/plab/Makefile index 6f954f2..5222e67 100644 --- a/plab/Makefile +++ b/plab/Makefile @@ -1,3 +1,6 @@ build: mkdir -p out - go build -v -race -ldflags "-linkmode external -extldflags '-static'" -a -o out/plab \ No newline at end of file + go build -v -race -ldflags "-linkmode external -extldflags '-static'" -a -o out/plab + +podman: + podman run --rm -it -v $PWD:/build golang:alpine sh -c "apk add make build-base; cd /build; make" \ No newline at end of file diff --git a/plab/javadoc.go b/plab/javadoc.go index d30062e..95a87fa 100644 --- a/plab/javadoc.go +++ b/plab/javadoc.go @@ -11,10 +11,19 @@ import ( "strings" ) +type annotated interface { + GetAnnot() []Annot +} + type InternalType struct { Name string QualifiedName string DocString string + Annotations []Annot +} + +func (i *InternalType) GetAnnot() []Annot { + return i.Annotations } type Annot struct { @@ -26,25 +35,22 @@ type Annot struct { } type Params struct { - Name string - Annotations []Annot - Type InternalType + InternalType + Type InternalType } type Method struct { InternalType - Parameters []Params - ReturnType InternalType - Exceptions []struct{} // TODO - Annotations []Annot - Modifiers string + Parameters []*Params + ReturnType InternalType + Exceptions []struct{} // TODO + Modifiers string } type Field struct { InternalType - Annotations []Annot - Modifiers string - Type InternalType + Modifiers string + Type InternalType } type Class struct { @@ -58,10 +64,9 @@ type Class struct { InternalType realClass *Class } - Methods []*Method - Annotations []Annot - Modifiers string - Fields []*Field + Methods []*Method + Modifiers string + Fields []*Field } func (c *Class) getMethod(name string) *Method { @@ -144,21 +149,52 @@ func readJson(fname string) (*Class, error) { return nil, e } - for i, f := range c.Fields { - ann := f.Annotations - for _, a := range ann { - if a.TypeName == "Docs" { - for _, e := range a.Elements { - switch e.QualifiedName { - case "projlab.Docs.type": - e.Value = strings.ReplaceAll(e.Value, "\"", "") - c.Fields[i].Type.Name = e.Value + replaceFieldType := func(field interface{}, newType string) { + field.(*Field).Type.Name = newType + } + replaceMethodType := func(field interface{}, newType string) { + field.(*Method).ReturnType.Name = newType + } + replaceMethodParamType := func(field interface{}, newType string) { + field.(*Params).Type.Name = newType + } + do := func(arr []annotated, replace func(field interface{}, newType string)) { + for i, f := range arr { + ann := f.GetAnnot() + for _, a := range ann { + if a.TypeName == "Docs" { + for _, e := range a.Elements { + switch e.QualifiedName { + case "projlab.Docs.type": + e.Value = strings.ReplaceAll(e.Value, "\"", "") + replace(arr[i], e.Value) + } } } } } } + tmp := make([]annotated, 0, len(c.Fields)) + for i := range tmp { + tmp[i] = &c.Fields[i].InternalType + } + do(tmp, replaceFieldType) + + tmp = make([]annotated, 0, len(c.Methods)) + for i := range tmp { + tmp[i] = &c.Methods[i].InternalType + } + do(tmp, replaceMethodType) + + tmp = make([]annotated, 0) + for i := range c.Methods { + for j := range c.Methods[i].Parameters { + tmp = append(tmp, c.Methods[i].Parameters[j]) + } + } + do(tmp, replaceMethodParamType) + return &c, e } -- GitLab