Skip to content

Commit

Permalink
feat(generate-examples-index)!: complete overhaul (#6)
Browse files Browse the repository at this point in the history
* feat(generate-examples-index)!: complete overhaul

BREAKING CHANGE: The API differs a lot.

Vuepress compatible Markdown output. I would like all of the stuff to be
a part of Vuepress so that we don't have different design for each thing
like we do now. I hope you won't protest against this.

Styles and playground data are now separated from HTML. This decreased
the size of index.html by an order of magnitude (from about 1 MiB to
less than 100 KiB in Vis Network). Previously all the code (JS, HTML and
CSS) for each example was in the index itself twice (once for JSFiddle
and once for CodePen). This wasn't that big of a deal for browsers (what
is a megabyte here or there nowadays) but it made Vuepress crash. The
problem was that it interpreted only a part of the attributes containing
the code and tried to interpret the remainder as Markdown/HTML and ended
with errors because the remainder wasn't valid. This way a static page
with code only for one example is opened and a form button in it is
automatically clicked by JS to open the playground.

The generated HTML is generally simplyfied with only small tweaks to
design. These include playground links being first instead of last and
the images having blue background when they fail to load instead of
being transparent.

More information is logged to the console for easier debugging and just
to give better idea about what is going on.

The directory structure of generated files is now more finely
configurable. This is necessary for Vuepress compatibility.

Configuration can now be saved in a JSON file instead of an awkwardly
long argument list in package.json.

Internally it is now modular instead of monolithic. This is important
for HTML and Markdown coexistence as well as general maintainability (it
turned out much bigger than I originally expected).

* test(generate-examples-index): add pinning tests

* docs(generate-examples-index): various changes

Mostly added docs and other comments explaining what's going on in the
code. There is also some minor refactoring and other small changes that
don't affect the functionality.

* fix(generate-examples-index): produce the same hash everywhere

The support files use path hashes for unique identification. The
absolute path was used which resulted in CI tests failing because the
path was different on each computer. This should resolve the issue.

Also since it is the same for all URLs related to the same example it is
now generated only once for each example and reused rather than
regenerated for each URL again.
  • Loading branch information
Thomaash committed Jan 5, 2020
1 parent ba46072 commit 6495c63
Show file tree
Hide file tree
Showing 31 changed files with 4,458 additions and 875 deletions.
1 change: 1 addition & 0 deletions .eslintignore
@@ -1,4 +1,5 @@
!/.eslintrc
/__snapshots__
/bin
/declarations
/dist
Expand Down
2,712 changes: 2,712 additions & 0 deletions __snapshots__/test/generate-examples-index/basic.test.ts.js

Large diffs are not rendered by default.

235 changes: 235 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions package.json
Expand Up @@ -35,6 +35,12 @@
"pre-push": "npm test"
}
},
"config": {
"snap-shot-it": {
"sortSnapshots": true,
"useRelativePath": true
}
},
"main": "dist/vis-dev-utils.cjs.js",
"module": "dist/vis-dev-utils.esm.js",
"types": "declarations",
Expand Down Expand Up @@ -107,6 +113,7 @@
"rollup-plugin-string": "^3.0.0",
"rollup-plugin-typescript2": "^0.24.3",
"sinon": "^7.5.0",
"snap-shot-it": "^7.9.1",
"tmp-promise": "^2.0.2",
"typescript": "^3.6.3"
},
Expand Down

0 comments on commit 6495c63

Please sign in to comment.