Skip to content

Commit

Permalink
Drop excessive data in test files (#11)
Browse files Browse the repository at this point in the history
1.  Deleted base64-encoded image data from test / example notebooks and updated "golden" files:
  -  example/nbee/notebook.ipynb had 2 base64 images and weighted a whopping 273 KB. That's a lot of useless data to move around, considering that nbee is just an example for documentation purposes.
  - testdata/notebook.ipynb had 1 base64 image, which took up ~85% of its size -- that that image is part of the golden-file test is not essential, as rendering of images from a mime-bundle is well-tested in other unit tests
  - Finally, because of so much .ipynb kilobytes, Github would assume nb was a predominantly-Jupyter-notebook-project, which is just not right :)

2. Fixed incorrect installation guide in the README for example/nbee
  • Loading branch information
bevzzz authored Jan 31, 2024
1 parent a7c6647 commit 40a335d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 256 deletions.
1 change: 1 addition & 0 deletions example/nbee/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
golang 1.18
18 changes: 14 additions & 4 deletions example/nbee/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,30 @@
Compile the package on the fly 🐝

```sh
go run github.com/bevzzz/nb/example/nbee
go run github.com/bevzzz/nb/example/nbee -f path/to/notebook.ipynb
```

Or, install a binary 🗑

```sh
go install github.com/bevzzz/nb/example/nbee
# Build from source:
git clone https://github.com/bevzzz/nb.git
cd nb/example/nbee
go install

# Install from remote repository (Go 1.17+):
go install github.com/bevzzz/nb/example/nbee@latest
```

Try it out:

```sh
nbee # convert the default notebook to HTML
nbee -f "my_notebook.ipynb" # convert your own notebooks
# If you already have bevzzz/nb checked out:
cd nb/testdata
nbee -f notebook.ipynb

# Convert your own notebooks
nbee -f my_jupyter.ipynb
```

## Disclaimer
Expand Down
16 changes: 8 additions & 8 deletions example/nbee/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ import (
synth "github.com/bevzzz/nb-synth"
"github.com/bevzzz/nb/extension"
"github.com/bevzzz/nb/extension/adapter"
jupyter "github.com/bevzzz/nb/extension/extra/goldmark-jupyter"
"github.com/bevzzz/nb/render"
"github.com/bevzzz/nb/render/html"
jupyter "github.com/bevzzz/nb/extension/extra/goldmark-jupyter"
"github.com/robert-nix/ansihtml"
"github.com/yuin/goldmark"
highlighting "github.com/yuin/goldmark-highlighting/v2"
)

var (
file = flag.String("f", "notebook.ipynb", "Jupyter notebook file")
file = flag.String("f", "", "Jupyter notebook file")
)

//go:embed notebook.ipynb
var defaultNotebook []byte

func main() {
flag.Parse()
var err error
if *file == "" {
log.Fatal("-f must be a valid path to notebook")
}

b := defaultNotebook
var b []byte
var err error
outFile := "notebook.html"

if f := *file; file != nil {
if f := *file; f != "" {
if b, err = os.ReadFile(f); err != nil {
log.Fatal(err)
}
Expand Down
237 changes: 0 additions & 237 deletions example/nbee/notebook.ipynb

This file was deleted.

7 changes: 2 additions & 5 deletions testdata/notebook.golden

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions testdata/notebook.ipynb

Large diffs are not rendered by default.

0 comments on commit 40a335d

Please sign in to comment.