-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix code bug and add documentation (#467)
- Loading branch information
1 parent
35d40c9
commit 8a057a1
Showing
16 changed files
with
374 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/johnfercher/maroto/v2/pkg/components/code" | ||
"github.com/johnfercher/maroto/v2/pkg/components/image" | ||
"github.com/johnfercher/maroto/v2/pkg/components/text" | ||
"github.com/johnfercher/maroto/v2/pkg/props" | ||
|
||
"github.com/johnfercher/maroto/v2/pkg/core" | ||
|
||
"github.com/johnfercher/maroto/v2" | ||
|
||
"github.com/johnfercher/maroto/v2/pkg/config" | ||
) | ||
|
||
func main() { | ||
m := GetMaroto() | ||
document, err := m.Generate() | ||
if err != nil { | ||
log.Fatal(err.Error()) | ||
} | ||
|
||
err = document.Save("docs/assets/pdf/autorow.pdf") | ||
if err != nil { | ||
log.Fatal(err.Error()) | ||
} | ||
|
||
err = document.GetReport().Save("docs/assets/text/autorow.txt") | ||
if err != nil { | ||
log.Fatal(err.Error()) | ||
} | ||
} | ||
|
||
func GetMaroto() core.Maroto { | ||
cfg := config.NewBuilder(). | ||
WithDebug(true). | ||
Build() | ||
|
||
mrt := maroto.New(cfg) | ||
m := maroto.NewMetricsDecorator(mrt) | ||
|
||
m.AddAutoRow( | ||
image.NewFromFileCol(5, "docs/assets/images/biplane.jpg"), | ||
text.NewCol(7, intro), | ||
) | ||
|
||
m.AddAutoRow( | ||
image.NewFromFileCol(5, "docs/assets/images/biplane.jpg"), | ||
text.NewCol(7, intro, props.Text{ | ||
Size: 13, | ||
}), | ||
) | ||
|
||
m.AddAutoRow( | ||
code.NewBarCol(4, "code"), | ||
text.NewCol(8, intro), | ||
) | ||
|
||
m.AddAutoRow( | ||
code.NewMatrixCol(3, "code"), | ||
text.NewCol(9, intro), | ||
) | ||
|
||
m.AddAutoRow( | ||
code.NewQrCol(2, "code"), | ||
text.NewCol(10, intro), | ||
) | ||
|
||
return m | ||
} | ||
|
||
var intro = `Numa toca no chão vivia um hobbit. Não uma toca nojenta, suja, úmida, | ||
cheia de pontas de minhocas e um cheiro de limo, nem tam pouco uma toca seca, vazia, arenosa, | ||
sem nenhum lugar onde se sentar ou onde comer: era uma toca de hobbit, e isso significa conforto. | ||
Ela tinha uma porta perfeitamente redonda feito uma escotilha, pintada de verde, com uma maçaneta | ||
amarela e brilhante de latão exatamente no meio. A porta se abria para um corredor em forma de tubo, | ||
feito um túnel: um túnel muito confortável, sem fumaça, de paredes com painéis e assoalhos | ||
azulejados e acarpetados, com cadeiras enceradas e montes e montes de cabieiros para chapéus e | ||
casacos - o hobbit apreciava visitas.` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/johnfercher/maroto/v2/pkg/test" | ||
) | ||
|
||
func TestGetMaroto(t *testing.T) { | ||
// Act | ||
sut := GetMaroto() | ||
|
||
// Assert | ||
test.New(t).Assert(sut.GetStructure()).Equals("examples/autorow.json") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
generate -> avg: 2.94ms, executions: [2.94ms] | ||
file_size -> 219.47Kb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
generate -> avg: 5.22ms, executions: [5.22ms] | ||
add_row -> avg: 245.50ns, executions: [544.00ns, 209.00ns, 101.00ns, 81.00ns, 80.00ns, 458.00ns] | ||
add_rows -> avg: 77.00ns, executions: [121.00ns, 87.00ns, 40.00ns, 90.00ns, 37.00ns, 87.00ns] | ||
generate -> avg: 4.97ms, executions: [4.97ms] | ||
add_row -> avg: 325.33ns, executions: [946.00ns, 211.00ns, 103.00ns, 91.00ns, 92.00ns, 509.00ns] | ||
add_rows -> avg: 76.50ns, executions: [127.00ns, 85.00ns, 41.00ns, 87.00ns, 36.00ns, 83.00ns] | ||
file_size -> 28.15Kb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Add Row | ||
|
||
## GoDoc | ||
* [constructor : New](https://pkg.go.dev/github.com/johnfercher/maroto/v2/pkg/components/page#New) | ||
* [interface : Page](https://pkg.go.dev/github.com/johnfercher/maroto/v2/pkg/core#Page) | ||
* [props : Page](https://pkg.go.dev/github.com/johnfercher/maroto/v2/pkg/props#Page) | ||
|
||
## Code Example | ||
[filename](../../assets/examples/autorow/v2/main.go ':include :type=code') | ||
|
||
## PDF Generated | ||
assets/pdf/autorow.pdf | ||
``` | ||
|
||
## Time Execution | ||
[filename](../../assets/text/autorow.txt ':include :type=code') | ||
|
||
## Test File | ||
[filename](https://raw.githubusercontent.com/johnfercher/maroto/master/test/maroto/examples/autorow.json ':include :type=code') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.