Skip to content
Snippets Groups Projects
Verified Commit 343e5631 authored by Tóth Miklós Tibor's avatar Tóth Miklós Tibor :shrug:
Browse files

changed

parent e8fd3ad8
Branches own-vm
No related tags found
No related merge requests found
Pipeline #7146 passed
......@@ -94,11 +94,54 @@ func (c *Class) getMethod(name string) *Method {
return nil
}
func (i *InternalType) changed() bool {
for _, a := range i.Annotations {
if a.changed() {
return true
}
}
return false
}
func (a *Annot) changed() bool {
if a.TypeName == "Docs" {
for _, e := range a.Elements {
switch e.QualifiedName {
case "projlab.Docs.changed":
if e.Value == "true" {
return true
}
}
}
}
return false
}
func (c *Class) changedClass() bool {
if c.changed() {
return true
}
for _, m := range c.Methods {
if m.changed() {
return true
}
}
for _, f := range c.Fields {
if f.changed() {
return true
}
}
return false
}
var Javadoc = helpers.Subcommand{
Name: "javadoc",
Command: func(args []string) {
if len(args) > 1 {
fmt.Println("usage: javadoc [source location]")
if len(args) > 2 {
fmt.Println("usage: javadoc [source location] [-changed]")
return
}
......@@ -117,7 +160,15 @@ var Javadoc = helpers.Subcommand{
classes = linkInheritance(classes)
classes = resolveDocsFromInheritance(classes)
printLatex(classes)
changed := false
for _, a := range args {
if a == "-changed" {
changed = true
break
}
}
printLatex(classes, changed)
},
Help: "create and parse javadoc from code",
}
......@@ -347,7 +398,7 @@ func resolveDocsFromInheritance(c map[string]*Class) map[string]*Class {
return c
}
func printLatex(c map[string]*Class) {
func printLatex(c map[string]*Class, changed bool) {
keys := make([]string, 0, len(c))
for k := range c {
keys = append(keys, k)
......@@ -359,14 +410,22 @@ func printLatex(c map[string]*Class) {
for _, k := range keys {
class := c[k]
printClassDoc(class)
printClassDoc(class, changed)
}
}
func printClassDoc(c *Class) {
fmt.Printf("\\subsubsection{\\texttt{%s \\textcolor{blue}{%s}}}\n", c.Modifiers, c.Name)
fmt.Println("\\begin{itemize}")
func printClassDoc(c *Class, changed bool) {
if changed && !c.changedClass() {
return
}
extra := ""
if !changed || c.changed() {
extra = "\\textit{Új osztály}"
}
fmt.Printf("\\subsubsection{\\texttt{%s \\textcolor{blue}{%s}} %s}\n", c.Modifiers, c.Name, extra)
fmt.Println("\\begin{itemize}")
if !changed || c.changed() {
if c.DocString != "" {
fmt.Println("\\item Felelősség:")
fmt.Println("\\newline")
......@@ -403,32 +462,50 @@ func printClassDoc(c *Class) {
}
fmt.Println("\\end{itemize}")
}
}
}
if changed && !c.changed() {
fmt.Println("\\item Változott attribútumok")
} else {
fmt.Println("\\item Attribútumok")
}
if len(c.Fields) == 0 {
fmt.Println("\\newline")
fmt.Println("\\emph{Nincsenek attribútumok}")
} else {
fmt.Println("\\begin{itemize}")
ch := false
for _, attr := range c.Fields {
if !changed || attr.changed() || c.changed() {
ch = true
fmt.Printf(`\item \texttt{%s \textcolor{blue}{%s} %s}`, attr.Modifiers, attr.Type.Name, attr.Name)
if attr.DocString != "" {
fmt.Printf(": %s", attr.DocString)
}
fmt.Println()
}
fmt.Println("\\end{itemize}")
}
if !ch {
fmt.Println("\\item \\textit{Nincsenek megváltozott attribútumok}")
}
fmt.Println("\\end{itemize}")
}
if changed && !c.changed() {
fmt.Println("\\item Megváltozott metódusok")
} else {
fmt.Println("\\item Metódusok")
}
if len(c.Methods) == 0 {
fmt.Println("\\newline")
fmt.Println("\\emph{Nincsenek metódusok}")
} else {
fmt.Println("\\begin{itemize}")
ch := false
for _, meth := range c.Methods {
if !changed || meth.changed() || c.changed() {
ch = true
fmt.Printf(`\item \texttt{%s \textcolor{blue}{`, meth.Modifiers)
fmt.Printf("%s} ", meth.ReturnType.Name)
fmt.Printf("%s(", meth.Name)
......@@ -445,6 +522,10 @@ func printClassDoc(c *Class) {
}
fmt.Println()
}
}
if !ch {
fmt.Println("\\item \\textit{Nincsenek megváltozott metódusok}")
}
fmt.Println("\n\\end{itemize}")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment