Skip to content

Commit

Permalink
Use docstrings instead of comments for generated Python code headers (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaloney authored Dec 10, 2023
1 parent 0b65f14 commit 411d148
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
23 changes: 13 additions & 10 deletions framework/ccm_pyactr/ccm_pyactr.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,29 +316,32 @@ func (c *CCMPyACTR) GenerateCode(initialBuffers framework.InitialBuffers) (code
}

func (c CCMPyACTR) writeHeader() {
c.Writeln("# Generated by gactar %s", framework.GactarVersion)
c.Writeln("# on %s", framework.TimeNow().Format("2006-01-02 @ 15:04:05"))
c.Writeln("# https://github.com/asmaloney/gactar")
c.Writeln("")
c.Writeln("# *** NOTE: This is a generated file. Any changes may be overwritten.")
c.Writeln("")
c.Writeln("\"\"\"")

if c.model.Description != "" {
c.Write("# %s\n\n", c.model.Description)
c.Write("%s\n\n", c.model.Description)
}

c.writeAuthors()

c.Writeln("Generated by gactar %s", framework.GactarVersion)
c.Writeln(" https://github.com/asmaloney/gactar")
c.Writeln(" on %s", framework.TimeNow().Format("2006-01-02 @ 15:04:05"))
c.Writeln("")
c.Writeln("NOTE: This is a generated file. Any changes may be overwritten.")

c.Writeln("\"\"\"\n")
}

func (c CCMPyACTR) writeAuthors() {
if len(c.model.Authors) == 0 {
return
}

c.Writeln("# Authors:")
c.Writeln("Authors:")

for _, author := range c.model.Authors {
c.Write("# %s\n", author)
c.Writeln(" %s", author)
}

c.Writeln("")
Expand Down Expand Up @@ -383,7 +386,7 @@ func (c CCMPyACTR) writeImports() {

if c.model.HasPrintStatement() {
c.Writeln("")
c.Writeln(fmt.Sprintf("from %s import *", ccmPrintImportName))
c.Writeln(fmt.Sprintf("from %s import CCMPrint", ccmPrintImportName))
}

if c.model.TraceActivations {
Expand Down
21 changes: 12 additions & 9 deletions framework/pyactr/pyactr.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,29 +336,32 @@ func (p *PyACTR) GenerateCode(initialBuffers framework.InitialBuffers) (code []b
}

func (p PyACTR) writeHeader() {
p.Writeln("# Generated by gactar %s", framework.GactarVersion)
p.Writeln("# on %s", framework.TimeNow().Format("2006-01-02 @ 15:04:05"))
p.Writeln("# https://github.com/asmaloney/gactar")
p.Writeln("")
p.Writeln("# *** NOTE: This is a generated file. Any changes may be overwritten.")
p.Writeln("")
p.Writeln("\"\"\"")

if p.model.Description != "" {
p.Write("# %s\n\n", p.model.Description)
p.Write("%s\n\n", p.model.Description)
}

p.writeAuthors()

p.Writeln("Generated by gactar %s", framework.GactarVersion)
p.Writeln(" https://github.com/asmaloney/gactar")
p.Writeln(" on %s", framework.TimeNow().Format("2006-01-02 @ 15:04:05"))
p.Writeln("")
p.Writeln("NOTE: This is a generated file. Any changes may be overwritten.")

p.Writeln("\"\"\"\n")
}

func (p PyACTR) writeAuthors() {
if len(p.model.Authors) == 0 {
return
}

p.Writeln("# Authors:")
p.Writeln("Authors:")

for _, author := range p.model.Authors {
p.Write("# %s\n", author)
p.Write(" %s\n", author)
}

p.Writeln("")
Expand Down

0 comments on commit 411d148

Please sign in to comment.