diff options
author | Kurt <kurt.w.jung@gmail.com> | 2019-05-18 08:08:21 -0400 |
---|---|---|
committer | Kurt <kurt.w.jung@gmail.com> | 2019-05-18 08:08:21 -0400 |
commit | 5f4e2f65402b9aa611f93b2fa14ea69bf7b26d2d (patch) | |
tree | 0866c2a0b794887b4aee16aa2be2a279917fe14e | |
parent | e4895cb2e4a6b49e241d7668740c1a557ef4b8c5 (diff) |
Generalize awk script that produces doc.go
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | contrib/gofpdi/gofpdi.go | 11 | ||||
-rw-r--r-- | doc/go.awk | 12 |
3 files changed, 10 insertions, 15 deletions
@@ -19,7 +19,7 @@ doc/index.html : doc/document.md doc/html.txt --metadata pagetitle="GoFPDF Document Generator" < $< > $@ doc.go : doc/document.md doc/go.awk - pandoc --read=markdown --write=plain $< | awk -f doc/go.awk > $@ + pandoc --read=markdown --write=plain $< | awk --assign=package_name=gofpdf --file=doc/go.awk > $@ gofmt -s -w $@ build : diff --git a/contrib/gofpdi/gofpdi.go b/contrib/gofpdi/gofpdi.go index d1b98e9..b951ea3 100644 --- a/contrib/gofpdi/gofpdi.go +++ b/contrib/gofpdi/gofpdi.go @@ -17,8 +17,9 @@ type gofpdiPdf interface { SetError(err error) } -// Imports a page of a PDF file with the specified box (/MediaBox, /TrimBox, /ArtBox, /CropBox, or /BleedBox). -// Returns a template id that can be used with UseImportedTemplate to draw the template onto the page. +// ImportPage imports a page of a PDF file with the specified box (/MediaBox, +// /TrimBox, /ArtBox, /CropBox, or /BleedBox). Returns a template id that can +// be used with UseImportedTemplate to draw the template onto the page. func ImportPage(f gofpdiPdf, sourceFile string, pageno int, box string) int { // Set source file for fpdi fpdi.SetSourceFile(sourceFile) @@ -51,9 +52,9 @@ func ImportPage(f gofpdiPdf, sourceFile string, pageno int, box string) int { return tpl } -// Draw the template onto the page at x,y -// If w is 0, the template will be scaled to fit based on h -// If h is 0, the template will be scaled to fit based on w +// UseImportedTemplate draws the template onto the page at x,y. If w is 0, the +// template will be scaled to fit based on h. If h is 0, the template will be +// scaled to fit based on w. func UseImportedTemplate(f gofpdiPdf, tplid int, x float64, y float64, w float64, h float64) { // Get values from fpdi tplName, scaleX, scaleY, tX, tY := fpdi.UseTemplate(tplid, x, y, w, h) @@ -1,12 +1,6 @@ -BEGIN { - show = 0 - print "/*" -} +BEGIN { show = 0 ; print "/*" } -/^\-/ { - trim = 1 - print "" -} +/^\-/ { trim = 1 ; print "" } /^Package/ { show = 1 } @@ -16,4 +10,4 @@ trim { sub("^ +", "", $0) } show { print $0 } -END { print "*/\npackage gofpdf" } +END { print "*/\npackage " package_name } |