From 5f4e2f65402b9aa611f93b2fa14ea69bf7b26d2d Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 18 May 2019 08:08:21 -0400 Subject: Generalize awk script that produces doc.go --- Makefile | 2 +- contrib/gofpdi/gofpdi.go | 11 ++++++----- doc/go.awk | 12 +++--------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index f2590bd..90624c5 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/doc/go.awk b/doc/go.awk index a325362..bcd4a7c 100644 --- a/doc/go.awk +++ b/doc/go.awk @@ -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 } -- cgit v1.2.1-24-ge1ad