A collection of code snippet examples to assist working on CoCalc → read more.
The source files are in
/src and are processed via the
examples.py Python file.
Usually, just running
make in the main directory is enough to see if the changes did work.
The output is a unified
examples.json file, which can be used by other tools -- right now that's CoCalc.
All examples are collected in
The structure of a file is to specify
- meta-information of a sequence of example yaml docs. A file starts with them, and there can be additional meta-information documents (which replace the previous one):
categoryand sub-category, either as an array of strings or a string with
variables: a map to initialize variables
sortweightto override lexicographic sorting. (e.g. to place "Introduction" categories at the top)
- After a category specification, the entries for the examples are made of
- Optionally, a field
test, which could either be a doc-test (in case it is a string) or
false. In the latter case, it signals any testing framework to skip this test.
--- language: sage category: Mathematics / Introduction sortweight: -1 --- title: Introduction descr: | SageMath is an advanced Python-based environment for mathematics. With that foundation, it is also suited for scientific computing, statistics, and data analysis. Run `version()` to see which version of Sage you're currently working with. code: | version() --- title: Pitfalls descr: | There is a blurry line between using SageMath and programming. Function calls are always `function_name(...)` with round brackets, too. code: | # TODO: fix this expression var('x') sqrt [ (4 + x) (2 - x) ] test: false
to test the
make LANG=sage test
To speed things up and skip restarting the kernel (could give false positives, but syntax errors are always triggered)
make LANG=sage MODE=fast test
make testtest runs the
It's purpose is to confirm that breaking tests show up properly and the examples are read correctly.
When used as a submodule, one suitable magic git commands to update all submodules is
git submodule foreach "git fetch origin; git checkout master; git reset --hard origin/master"
Code: Apache 2.0
Creative Commons: Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) (more detailed information is in the header of the files in