- ensure the prerequisites are installed.
- run
./script/setup
to install the dependencies.
Note: To update the dependencies, run ./script/update
- run
./script/fetch-html statistics
- Note: To see the list of books available see
./books.txt
- Note: This will require you to log in via ssh.
- Note: You can set the ssh username by running
USER=myusername ./script/fetch-html ...
- Note: You can set the remote server to pull from by running
HOST=dev.cnx.org ./script/fetch-html ...
- Note: You can run
./script/fetch-html --all
to fetch all the books
- Note: To see the list of books available see
- run
./script/bake-book statistics
You will first need to get the single-file HTML from the server (fetch-html
) and then convert the single-file HTML locally into the "baked" book via bake-book
. Once you have done the first part, you can run ./script/bake-book statistics
to your ❤️'s content!
The steps to add a new book (like dark-matter-for-dummies
) are:
- Find the UUID of the book you want
- point your browser to the server containing the book (ie
cnx.org
) and find a book you want. - click "More Information" and copy the ID
- point your browser to the server containing the book (ie
- add an entry to
./books.txt
- run
./script/test
This will run the linter, generate sassdocs, and generate the guides to verify they work.
Recipe documentation can be found at ./recipes/ and an example config file.
- run
./script/generate-docs
to generate the SASS Docs - run
./script/generate-guide statistics
to generate the HTML Guide for a book - open the generated file in your browser
- run
./script/fetch-html ${book_name}
to fetch the Raw HTML for a book - run
./script/bake-book ${book_name}
- The HTML Report should now be available at
./coverage/
You can pass 3 arguments to report-book-coverage
to change how it reports coverage:
--verbose
: outputs verbose/debugging output--ignore-source-map
: covers the CSS even if a sourceMappingURL exists.--cover-declarations
: generates coverage based on the declarations, as well as the selector- Note: You can run
./script/report-book-coverage --all
to generate coverage using all the books
For more details on the commandline options see the css-coverage documentation.
Code coverage is a great way to see if your tests exercises all the features of the codebase.
In the case of this repositoriy, the "codebase" contains all the CSS recipe files and the "tests" are the HTML snippets used to create a style guide.
By checking the code coverage, whenever a new feature in a book is added, a corresponding example in the HTML guide should be added as well (code coverage will complain otherwise).
To rebake a book on a development instance. To do that, you will need to upload a CSS recipe file, trigger a rebake, and then clear the cache.
-
run
./script/compile-books
to generate the recipes CSS file -
run
./script/bake-book-remote ${BOOK_NAME} ${VERSION}
to upload, trigger, and clear the cache${BOOK_NAME]
is the book’s name in the book list of/books.txt
${VERSION]
is the@#.##
in the target collection URL
For example, you want to rebake the "cooking" book:
- you can run
./script/bake-book-remote cooking
and it will tell you to go tohttp://foo.cnx.org/contents/${UUID}
- find the version (ie
7.16
) by looking at the URL or by clicking “More Information” at the bottom of the page - run
./script/bake-book-remote cooking 7.16
(using that version you found)
To check that there were no regressions in a book you will need to do the following:
- bake the book with the old code
- bake the book with the new code
- compare the 2 baked HTML files to see if there were any differences
Here are the steps to run it:
# Prep work (run once)
./script/setup
./script/fetch-html statistics # Or any book in ./books.txt
# Check out the old version from git (ie `master` branch)
# Then run:
./script/diff-book-prepare statistics
# Check out the new code from git (ie `shiny-unincorns` branch)
# Then run:
./script/diff-book statistics
# Any differences would pop up at this point
# Optional: Create a diff and give it to a GUI
diff ./data/statistics-prepared.xhtml ./data/statistics-baked.xhtml > foo.diff
Note: You can specify --all
instead of statistics
to diff all the books (after fetching them earlier)
Instead of diffing the whole book, you can find differences in the styleguide for a recipe (faster and easier to find errors because the HTML files are much smaller than an entire book).
To do this, just replace every occurrence of ./script/diff-book ${BOOK_NAME}
(and ./script/diff-book-prepare
) with diff-guide ${RECIPE_NAME}
in the instructions above.
To update the Documentation in the gh-pages branch:
git checkout master
./script/generate-and-update-gh-pages
Note: This will push changes if successful