rename and docs

This commit is contained in:
Júlio César Batista 2023-04-05 15:34:50 -03:00
parent f0adecf1dc
commit eb2518c0e4
No known key found for this signature in database
GPG key ID: 10C4B861BF314878
4 changed files with 14 additions and 10 deletions

View file

@ -35,7 +35,7 @@ import (
"oss.terrastruct.com/d2/lib/pdf"
pdflib "oss.terrastruct.com/d2/lib/pdf"
"oss.terrastruct.com/d2/lib/png"
"oss.terrastruct.com/d2/lib/ppt"
"oss.terrastruct.com/d2/lib/pptx"
"oss.terrastruct.com/d2/lib/textmeasure"
"oss.terrastruct.com/d2/lib/version"
@ -368,7 +368,7 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, rende
if user, err := user.Current(); err != nil {
username = user.Username
}
p := ppt.NewPresentation(rootName, rootName, rootName, username, version.Version)
p := pptx.NewPresentation(rootName, rootName, rootName, username, version.Version)
err := renderPPTX(ctx, ms, p, plugin, renderOpts, outputPath, page, diagram, nil)
if err != nil {
return nil, false, err
@ -759,7 +759,7 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opt
return svg, nil
}
func renderPPTX(ctx context.Context, ms *xmain.State, presentation *ppt.Presentation, plugin d2plugin.Plugin, opts d2svg.RenderOpts, outputPath string, page playwright.Page, diagram *d2target.Diagram, boardPath []string) error {
func renderPPTX(ctx context.Context, ms *xmain.State, presentation *pptx.Presentation, plugin d2plugin.Plugin, opts d2svg.RenderOpts, outputPath string, page playwright.Page, diagram *d2target.Diagram, boardPath []string) error {
var currBoardPath []string
// Root board doesn't have a name, so we use the output filename
if diagram.Name == "" {

View file

@ -1,4 +1,4 @@
package ppt
package pptx
import (
"archive/zip"

View file

@ -1,4 +1,13 @@
package ppt
// pptx is a package to create slide presentations in pptx (Microsoft Power Point) format.
// A `.pptx` file is just a bunch of zip compressed `.xml` files following the Office Open XML (OOXML) format.
// To see its content, you can just `unzip <path/to/file>.pptx -d <folder>`.
// With this package, it is possible to create a `Presentation` and add `Slide`s to it.
// Then, when saving the presentation, it will generate the required `.xml` files, compress them and write to the disk.
// Note that this isn't a full implementation of the OOXML format, but a wrapper around it.
// There's a base template with common files to the presentation and then when saving, the package generate only the slides and relationships.
// The base template and slide templates were generated using https://python-pptx.readthedocs.io/en/latest/
// For more information about OOXML, check http://officeopenxml.com/index.php
package pptx
import (
"archive/zip"
@ -9,11 +18,6 @@ import (
"os"
)
// TODO: comments / references / assumptions
// TODO: update core files with metadata
// TODO: links?
// TODO: appendix?
type Presentation struct {
Title string
Description string