go(report_base): add in-text timestamp
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ed2aece330
commit
988c20885e
@ -20,8 +20,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
//go:embed report_base.tex
|
//go:embed report_base.tmpl
|
||||||
reportBase []byte
|
tmplReportBaseFile []byte
|
||||||
//go:embed meta.sty
|
//go:embed meta.sty
|
||||||
metaSty []byte
|
metaSty []byte
|
||||||
//go:embed report.tmpl
|
//go:embed report.tmpl
|
||||||
@ -38,6 +38,32 @@ func GetPicsDir() string {
|
|||||||
return outPrefix + picsDir
|
return outPrefix + picsDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func emitReportBaseTex() error {
|
||||||
|
fname := GetTexDir() + "report_base.tex"
|
||||||
|
|
||||||
|
f, err := os.Create(fname)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
tmplReportBase := template.New("report_base")
|
||||||
|
tmplReportBase = template.Must(tmplReportBase.Parse(string(tmplReportBaseFile)))
|
||||||
|
|
||||||
|
err = tmplReportBase.Execute(f, struct {
|
||||||
|
Timestamp time.Time
|
||||||
|
}{
|
||||||
|
Timestamp: time.Now(),
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func emitReportTex(fname string) error {
|
func emitReportTex(fname string) error {
|
||||||
f, err := os.Create(fname)
|
f, err := os.Create(fname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -50,11 +76,9 @@ func emitReportTex(fname string) error {
|
|||||||
tmplReport = template.Must(tmplReport.Parse(string(tmplReportFile)))
|
tmplReport = template.Must(tmplReport.Parse(string(tmplReportFile)))
|
||||||
|
|
||||||
err = tmplReport.Execute(f, struct {
|
err = tmplReport.Execute(f, struct {
|
||||||
ReportBase string
|
Timestamp time.Time
|
||||||
Timestamp time.Time
|
|
||||||
}{
|
}{
|
||||||
ReportBase: string(reportBase),
|
Timestamp: time.Now(),
|
||||||
Timestamp: time.Now(),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -81,9 +105,14 @@ func saveMetaSty() error {
|
|||||||
// SaveAndPrint emits the tex files necessary to compile the report in full
|
// SaveAndPrint emits the tex files necessary to compile the report in full
|
||||||
// (report.tex, meta.sty) and prints the report.tex file to console.
|
// (report.tex, meta.sty) and prints the report.tex file to console.
|
||||||
func SaveAndPrint(doPrint bool) {
|
func SaveAndPrint(doPrint bool) {
|
||||||
fname := "report.tex"
|
err := emitReportBaseTex()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
err := emitReportTex(fname)
|
reportFname := "report.tex"
|
||||||
|
|
||||||
|
err = emitReportTex(reportFname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -96,7 +125,7 @@ func SaveAndPrint(doPrint bool) {
|
|||||||
if doPrint {
|
if doPrint {
|
||||||
fmt.Fprint(os.Stderr, "\n* printing the report...\n\n")
|
fmt.Fprint(os.Stderr, "\n* printing the report...\n\n")
|
||||||
|
|
||||||
fh, err := os.Open(fname)
|
fh, err := os.Open(reportFname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
% Code generated by go generate; DO NOT EDIT.
|
% Code generated by math-optim; DO NOT EDIT.
|
||||||
% This file was generated by robots at
|
% This file was generated by robots at
|
||||||
% {{ .Timestamp }}
|
% {{ .Timestamp }}
|
||||||
% source: git.dotya.ml/wanderer/math-optim/report/report.tmpl
|
% source: git.dotya.ml/wanderer/math-optim/report/report.tmpl
|
||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
% begin report.tmpl
|
% begin report.tmpl
|
||||||
|
|
||||||
{{ .ReportBase -}}
|
\input{out/tex/report_base.tex}
|
||||||
|
|
||||||
% end report.tmpl
|
% end report.tmpl
|
||||||
|
|
||||||
|
@ -36,8 +36,9 @@
|
|||||||
\vspace*{\fill}
|
\vspace*{\fill}
|
||||||
\begin{center}
|
\begin{center}
|
||||||
\Large
|
\Large
|
||||||
This file was generated by robots.\\source:
|
The template of this file was generated by robots at\\
|
||||||
\href{https://git.dotya.ml/wanderer/math-optim/}{\texttt{math-optim} project page}
|
\texttt{ {{- .Timestamp -}} }\\
|
||||||
|
source: \href{https://git.dotya.ml/wanderer/math-optim/}{\texttt{math-optim} project page}
|
||||||
\end{center}
|
\end{center}
|
||||||
\vspace*{\fill}
|
\vspace*{\fill}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user