From e207247c4b7899011ca41381fd022d36fd9f6e1b Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Tue, 3 Apr 2018 11:53:16 +0200 Subject: [PATCH] godoc for converter package + fixing typo in godoc of process package --- app/handlers/converter/converter.go | 9 +++++++++ app/handlers/converter/process/process.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/handlers/converter/converter.go b/app/handlers/converter/converter.go index 0b95fd4f..2e2ad8de 100644 --- a/app/handlers/converter/converter.go +++ b/app/handlers/converter/converter.go @@ -1,3 +1,4 @@ +// Package converter implements a solution for converting one or more files to PDF. package converter import ( @@ -12,17 +13,21 @@ import ( "github.com/satori/go.uuid" ) +// Converter handles conversion into PDF of files coming from a request. type Converter struct { files []*gfile.File workingDir string } +// NoFileToConvertError is raised when the converter has no file +// to convert. type NoFileToConvertError struct{} func (e *NoFileToConvertError) Error() string { return "There is no file to convert" } +// NewConverter instantiates a converter by parsing a request. func NewConverter(r *http.Request, contentType ghttp.ContentType) (*Converter, error) { c := &Converter{ workingDir: fmt.Sprintf("./%s/", uuid.NewV4().String()), @@ -77,6 +82,9 @@ func NewConverter(r *http.Request, contentType ghttp.ContentType) (*Converter, e return c, nil } +// Convert converts its associated files to PDF. If more than one file, +// it will merge all of them into one unique PDF file. +// Returns the new file path or an error if something bad happened. func (c *Converter) Convert() (string, error) { var filesPaths []string for _, f := range c.files { @@ -104,6 +112,7 @@ func (c *Converter) Convert() (string, error) { return path, nil } +// Clear removes all file inside its working directory. func (c *Converter) Clear() error { if err := os.RemoveAll(c.workingDir); err != nil { return err diff --git a/app/handlers/converter/process/process.go b/app/handlers/converter/process/process.go index 4b358224..e019f222 100644 --- a/app/handlers/converter/process/process.go +++ b/app/handlers/converter/process/process.go @@ -69,7 +69,7 @@ func Unconv(workingDir string, file *gfile.File) (string, error) { return cmdData.ResultFilePath, nil } -// mergeDAta will be applied to the data-driven template of the merge command. +// mergeData will be applied to the data-driven template of the merge command. type mergeData struct { FilesPaths []string ResultFilePath string