Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The SAW Documentation Revolution (Part 1) #2202

Merged
merged 82 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
51c669e
doc/internal: Move internal docs to an appropriate directory.
ChrisEPhifer Jan 25, 2025
dc42594
manual/code: Remove unused files.
ChrisEPhifer Jan 25, 2025
6b94ef9
manual: Correct erroneous internal links.
ChrisEPhifer Jan 25, 2025
a2af838
manual: Use a level-1 heading (slightly) more appropriately.
ChrisEPhifer Jan 25, 2025
85e4f55
Update fenced code block language specifiers.
ChrisEPhifer Jan 25, 2025
ea27d89
rust-tutorial: Subtract 1 from all headings after the first.
ChrisEPhifer Jan 25, 2025
e050f28
Normalize the title of the first chapter of each part.
ChrisEPhifer Jan 25, 2025
0df6156
tutorial: Remove PDF (+ generation) and split up tutorial.md.
ChrisEPhifer Jan 25, 2025
f5e4945
tutorial: Consistently use standard Markdown headings.
ChrisEPhifer Jan 25, 2025
748ed1d
tutorial: Use consistent code block style.
ChrisEPhifer Jan 25, 2025
49a85d9
tutorial: Repair broken code references.
ChrisEPhifer Jan 25, 2025
a362222
Move figures directory from tutorial to doc root.
ChrisEPhifer Jan 25, 2025
f9396ec
Rename tutorial -> llvm-java-tutorial.
ChrisEPhifer Jan 25, 2025
e98eea5
llvm-java-tutorial: Update code block style to use colon fences.
ChrisEPhifer Jan 25, 2025
9a72549
rust-tutorial: Remove PDF generation and split up rust-tutorial.md.
ChrisEPhifer Jan 25, 2025
6fd1d87
rust-tutorial: Correct minor errors in Markdown.
ChrisEPhifer Jan 25, 2025
ba8c180
rust-tutorial: Normalize code blocks.
ChrisEPhifer Jan 26, 2025
81a6250
manual: Remove PDF (+ generation) and split up manual.md.
ChrisEPhifer Jan 26, 2025
d4d6411
manual: Correct minor errors in Markdown.
ChrisEPhifer Jan 26, 2025
a416bc9
manual: Further normalize Markdown.
ChrisEPhifer Jan 26, 2025
dba1454
Rename manual -> saw-user-manual.
ChrisEPhifer Jan 26, 2025
92e1d9b
Rename llvm-java-tutorial -> llvm-java-verification-with-saw.
ChrisEPhifer Jan 26, 2025
c4444d1
Rename rust-tutorial -> rust-verification-with-saw.
ChrisEPhifer Jan 26, 2025
c3eed8f
Rename internal -> development.
ChrisEPhifer Jan 26, 2025
e815bc9
Use explicit targets and internal references.
ChrisEPhifer Jan 26, 2025
66aaa4b
development: Split up extcore.md.
ChrisEPhifer Jan 27, 2025
cf1560f
limitations: Remove redundant table of contents.
ChrisEPhifer Jan 27, 2025
226b5ca
releasing: Fix link to `CHANGES.md`.
ChrisEPhifer Jan 27, 2025
8739b29
Preemptively add a useful reference label to the SAW user manual.
ChrisEPhifer Jan 27, 2025
c318c83
releasing: Clean whitespace, remove outdated saw.galois.com link.
ChrisEPhifer Jan 27, 2025
a235e05
Add indices for all SAW documentation.
ChrisEPhifer Jan 28, 2025
f808628
saw-lexer: Add a simple pygments lexer for SAWScript.
ChrisEPhifer Jan 28, 2025
71a2d4a
Prepare doc/ for Sphinx.
ChrisEPhifer Jan 28, 2025
b7e0232
Add a Script that creates a Python virtual environment for SAW docs.
ChrisEPhifer Jan 28, 2025
954ab67
Add helper script to build HTML/PDF documents with Sphinx.
ChrisEPhifer Jan 28, 2025
a15e5b7
Commit PDF renderings of the tutorials and manual.
ChrisEPhifer Jan 28, 2025
4266590
Add a doc/ README.
ChrisEPhifer Jan 28, 2025
76be262
Attempt to fix file-bundling in CI.
ChrisEPhifer Jan 28, 2025
e22e84b
Merge branch 'master' into 2197-deploying-saws-written-materials
ChrisEPhifer Jan 28, 2025
c484801
Fix integration tests that reference documentation code.
ChrisEPhifer Jan 29, 2025
43770b7
doc/bibliography: Restore the bib file from the LLVM/Java tutorial.
ChrisEPhifer Feb 1, 2025
4b34431
rust-verification-with-saw: Replace missing '`' in Cryptol type var.
ChrisEPhifer Feb 1, 2025
b1aa596
Corrections to spelling errors.
ChrisEPhifer Feb 1, 2025
8e0179e
doc/README: Add clarifying reference to description of `make_docs`.
ChrisEPhifer Feb 1, 2025
4971718
doc/README: Remove note about removing `saw-lexer`.
ChrisEPhifer Feb 1, 2025
0eb36f3
doc/README: Add clarifying reference about PDF titles.
ChrisEPhifer Feb 2, 2025
392ae5e
saw-lexer: Cleanup imports.
ChrisEPhifer Feb 1, 2025
98386e9
saw-lexer: Remove special 'Name.Builtin' handling.
ChrisEPhifer Feb 1, 2025
094cdc3
Remove CHANGES mirror from developer docs and restore link text.
ChrisEPhifer Feb 2, 2025
b455635
doc/development: Consolidate extcore documentation into extcore.md.
ChrisEPhifer Feb 2, 2025
53a5dda
Hide SAW developer documentation.
ChrisEPhifer Feb 2, 2025
af6132d
Rename doc/development -> doc/developer.
ChrisEPhifer Feb 2, 2025
d3a27d1
doc/setup_env: Use requirements.txt in the script's directory.
ChrisEPhifer Feb 2, 2025
d0ac195
Create a scripts directory.
ChrisEPhifer Feb 2, 2025
ba3f555
Remove make_docs.sh.
ChrisEPhifer Feb 2, 2025
cf63994
doc/Makefile: Remove / replace Sphinx's default comments.
ChrisEPhifer Feb 2, 2025
e4d1853
Add scripts/package_code.sh.
ChrisEPhifer Feb 2, 2025
b5f8ef1
Makefile: Re-implement the behaviors of the old make_docs.sh.
ChrisEPhifer Feb 2, 2025
54c9c53
Generate PDFs in a (hopefully-reproducible) way.
ChrisEPhifer Feb 2, 2025
ff63fbe
doc/README: Update to reflect recent changes.
ChrisEPhifer Feb 2, 2025
d902766
Merge branch 'master' into 2197-deploying-saws-written-materials
ChrisEPhifer Feb 2, 2025
0ea2d4e
Makefile: Use make's $(shell) function.
ChrisEPhifer Feb 2, 2025
fcb3ce5
sphinx-download-dir: Sphinx role to download directories.
ChrisEPhifer Feb 3, 2025
7c614fa
scripts/requirements: Add sphinx-download-dir.
ChrisEPhifer Feb 3, 2025
bb99e83
.gitignore: Going forward, ignore all tar.gz archives in doc/.
ChrisEPhifer Feb 3, 2025
0b9f94f
Use sphinx-download-dir in the documentation.
ChrisEPhifer Feb 3, 2025
61af74a
Remove scripts/package_code.sh (and Makefile uses of the same).
ChrisEPhifer Feb 3, 2025
34b9624
Update README to reflect sphinx-download-dir changes.
ChrisEPhifer Feb 3, 2025
f8c17f9
Add CHANGES.
ChrisEPhifer Feb 3, 2025
2739adf
Merge branch 'master' into 2197-deploying-saws-written-materials
ChrisEPhifer Feb 3, 2025
2f3970b
Merge branch 'master' into 2197-deploying-saws-written-materials
ChrisEPhifer Feb 3, 2025
02bcdfb
Merge branch 'master' into 2197-deploying-saws-written-materials
ChrisEPhifer Feb 7, 2025
700c83c
Merge branch 'master' into 2197-deploying-saws-written-materials
ChrisEPhifer Feb 10, 2025
b4f6873
saw-lexer: Don't highlight the solver names 'abc' and 'z3'.
ChrisEPhifer Feb 10, 2025
4ffdf3f
Makefile: Run venv commands in subshells.
ChrisEPhifer Feb 10, 2025
5522ca9
Update the handling of SOURCE_DATE_EPOCH.
ChrisEPhifer Feb 10, 2025
615e5ee
Makefile: Rename mostlyclean -> clean, clean -> distclean.
ChrisEPhifer Feb 10, 2025
c252224
.gitignore: Add .venv.
ChrisEPhifer Feb 10, 2025
a7cdfd1
README: Add a note about the build's use of Python environments.
ChrisEPhifer Feb 10, 2025
1601ed2
Update the LLVM tutorial and manual PDFs.
ChrisEPhifer Feb 10, 2025
c295daa
Don't include interactive removal of .tar.gz in the Makefile.
ChrisEPhifer Feb 10, 2025
e4f2123
README: Update text about the make cleanup rules.
ChrisEPhifer Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,17 @@ build_cryptol() {

bundle_files() {
mkdir -p dist dist/{bin,deps,doc,examples,include,lib}
mkdir -p dist/doc/{llvm-java-verification-with-saw,rust-verification-with-saw,saw-user-manual}

cp LICENSE README.md dist/
$IS_WIN || chmod +x dist/bin/*

(cd deps/cryptol-specs && git archive --prefix=cryptol-specs/ --format=tar HEAD) | (cd dist/deps && tar x)
cp doc/extcore.md dist/doc
cp doc/tutorial/sawScriptTutorial.pdf dist/doc/tutorial.pdf
cp doc/manual/manual.pdf dist/doc/manual.pdf
cp -r doc/tutorial/code dist/doc
cp doc/pdfs/llvm-java-verification-with-saw.pdf dist/doc/llvm-java-verification-with-saw
cp doc/pdfs/rust-verification-with-saw.pdf dist/doc/rust-verification-with-saw
cp doc/pdfs/saw-user-manual.pdf dist/doc/saw-user-manual
cp -r doc/llvm-java-verification-with-saw/code dist/doc/llvm-java-verification-with-saw
cp -r doc/rust-verification-with-saw/code dist/doc/rust-verification-with-saw
cp intTests/jars/galois.jar dist/lib
cp -r deps/cryptol/lib/* dist/lib
cp -r examples/* dist/examples
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## New Features

* SAW documentation is now under a single Sphinx umbrella, resulting in a
complete overhaul of the `doc/` directory (#1723). Generally speaking, all
_content_ has stayed the same, and only organization has changed. Most
importantly for users, the PDF artifacts included in CI-generated releases
have different names and render with Sphinx styling.

* Add a `bitwuzla` family of proof scripts that use the Bitwuzla SMT solver.

* Add a `:tenv` REPL command, which is like `:env` but prints the type
Expand Down
6 changes: 6 additions & 0 deletions doc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
__pycache__
*.egg-info
.venv

_build
*.tar.gz
sauclovian-g marked this conversation as resolved.
Show resolved Hide resolved
44 changes: 44 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# SAW Documentation Makefile
# This is derived from Sphinx's default Makefile
include scripts/epoch.mk

SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

SUPPORTED_DOCS = html latex latexpdf linkcheck

help:
$(info SAW Documentation (based on Sphinx))
$(info Setup Python environment: 'make setup-env')
$(info Supported document formats: 'make' + one of: $(SUPPORTED_DOCS))
$(info Install PDFs to repository: 'make install-pdf')
$(info Tidy code packages / docs: 'make mostlyclean')
$(info Tidy everything, including Python venv: 'make clean')

sphinx-help: setup-env
@(. .venv/bin/activate && $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O))

.PHONY: setup-env pdf install-pdf mostlyclean clean help $(SUPPORTED_DOCS)

setup-env:
scripts/setup_env.sh

pdf: latexpdf

install-pdf: latexpdf
mkdir -p pdfs
cp -f $(shell ls _build/latex/*.pdf | sed '/\/galois\.pdf$$/d') pdfs

clean:
rm -rf _build

distclean: clean
rm -rf .venv

$(SUPPORTED_DOCS): setup-env
@(SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} . .venv/bin/activate && $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O))

%:
$(error "Target '$@' unknown; try 'make help'.")
296 changes: 296 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
# SAW Documentation

Welcome to the home of all things SAW documentation!

This `README` covers:

- Building the documentation
- The structure of `doc/` (this directory), including how to add new materials
- Information for developers working on the Sphinx build itself, and not just
documentation content

## Building the documentation

For the sake of rapid editing and simple deployment, we have attempted to make
it as easy as possible to build SAW's documentation, especially for those only
interested in modifying the documentation _content_.

### Prerequisites

The only _strict_ requirement to build the documentation locally is a relatively
recent Python (>=3.9, to be safe - we aren't prioritizing making this work on
every Python under the sun), and `make`.

This is enough to generate the HTML versions of documentation, which is what is
deployed to <https://galoisinc.github.io/saw-script>.
sauclovian-g marked this conversation as resolved.
Show resolved Hide resolved

If you want to generate the PDFs that can be found in `doc/pdfs`, you'll also
need `xelatex`.
This will require a suitable TeX distribution.

Note that the build will create a Python virtual environment and download the
necessary dependencies via `pip` (see `doc/scripts/requirements.txt`).
You can explicitly run this step with `make setup-env`.

### `Makefile`

As is typical for Sphinx projects, SAW's documentation is built using `make`.

Our `Makefile` is a tailored version of that which is generated when starting a
new Sphinx project, in particular restricting the document formats that can be
targeted, and handling the setup of an appropriate Python environment in which
to run the Sphinx build.

Typing `make help` is the easiest way to get started.
The following targets are available:

- `help`: Display all of the most useful targets
- `sphinx-help`: Display Sphinx's built-in help (**NOTE:** Most of these targets
are purposefully made unavailable and won't do anything!)
- `setup-env`: Create a Python venv (in `doc/.venv/`) suitable for building the
documentation.
This tries not to do unnecessary work: If you already have a `doc/.venv/`, it
will simply install the dependencies the build requires.
- `package-code`: Create tar.gz archives of all `doc/**/code/` directories.
This can be used to provide downloads in the HTML rendering of the
documentation (see [below](#code-examples)).
- `install-pdf`: Build and install PDF renderings to `doc/pdfs/`.
- `clean`: Clear out all packaged code and Sphinx-generated files.
- `distclean`: All of the above, plus the Python environment.

`make help` always shows the most up-to-date list of supported document targets.

#### `scripts/`

This directory contains utility scripts (and the documentation's
`requirements.txt`) used to implement the `make` targets above.

- `scripts/setup_env.sh` creates and validates a suitable Python environment,
independent of the documentation build.
It uses the sibling `requirements.txt` file, and can be run anywhere you want
to create a `.venv/` suitable for building SAW documentation (though in most
cases, you'll just be running `make setup-env` in `doc/`).
- `scripts/package_code.sh` finds all directories named `code` in the file tree,
and if there is no sibling `code.tar.gz`, creates it.
This is the implementation of `make package-code`, but like
`scripts/setup_env.sh` can be run anywhere.

### Troubleshooting

1. If the build succeeds, but you aren't seeing all of the expected changes:

Try running `make mostlyclean` before rebuilding; Sphinx may have failed to
detect the changes you made, and you're seeing stale/cached output.
2. If you have unresolved reference warnings:

Sphinx has an incredibly robust cross-reference system, but it is easy to get
"wrong".
If using Markdown/MyST, make sure you are using references according to [this
documentation](https://myst-parser.readthedocs.io/en/latest/syntax/cross-referencing.html).
3. If the build fails:

Try a full `make clean` to wipe out the `.venv/` directory and start again in
a fresh environment.

If you still have trouble, you've likely uncovered a bug in the system.
Please [open an issue](https://github.com/GaloisInc/saw-script/issues) detailing
the expected behavior, the observed behavior, and instructions to reproduce the
observed behavior.

## Understanding `doc/`

This directory is the intended source root for all SAW documentation.

### Contents

- The `Makefile` is explained in more detail [above](#makefile).

- `conf.py` is our Sphinx configuration, which has been heavily customized from
the default Sphinx provides.

- `index.md` defines the top-level document hierarchy, and is the intended home
page of <https://galoisinc.github.io/saw-script>.

- The `bibliography/` directory contains BibTeX (and possibly other)
bibliographies.

- The `developer/` directory is an assortment of documentation mostly relevant
to developers of `saw-script`, including:

- Documentation of the SAWCore `extcore` format
- Limitations of SAW and its use
- The `saw-script` release process


- The `figures/` directory is used to store image files / similar resources used
throughout SAW documentation.

- The `pdfs/` directory is where committed versions of PDF renderings live.

- The `scripts/` directory is where scripts relevant to building the
documentation are located.
This includes a `requirements.txt` pinning dependencies for the Sphinx build.

- `saw-lexer` is a small Python package implementing a SAWScript `pygments`
lexer, so our documentation understands and properly renders fenced code
blocks labeled ```````sawscript````.

- `sphinx-download-dir` is a Python package implementing an extension for Sphinx
in the form of a _role_ (essentially, an inline element with some semantics)
for creating full-directory downloads more easily.
See [below](#code-examples) for usage detail.


The remaining directories correspond to individual SAW documentation resources
currently managed as part of this documentation ecosystem:

- `llvm-java-verification-with-saw/`
"LLVM/Java Verification with SAW"
This is a tutorial-style introduction to SAW
- `rust-verification-with-saw/`
"Rust Verification with SAW"
Like the above, but using the experimental MIR features
- `saw-user-manual/`
"SAW User Manual"
The only 'complete' SAW reference right now

### Non-contents

These are pieces of documentation in `saw-script` that are _not_ part of the
`doc/` ecosystem:

- `saw-core/doc/`: A lone TeX file, presumably describing formalism related to
the SAWCore intermediate representation
- `saw-remote-api/docs/`: An old Sphinx setup for SAW's Python remote API

### Adding new materials

Sphinx provides a great deal of flexibility, but we prefer to keep that
flexibility in check by maintaining a close correspondence between the directory
structure of `doc/` and the document hierarchy its contents define.

That said, to add new documentation material:

1. Create a new directory in `doc/` for your material.
Name it the same as your intended title, or an appropriate transformation (to
e.g. remove spaces/spcial characters).

Add an `index.md` file that will define the top-level of your material's
hierarchy with a `toctree`.
Feel free to make this `toctree` `:hidden:`, give it a `:caption:`, or make
any other decisions appropriate for your material.
As long as the `toctree` is defined, even if it is hidden Sphinx will do the
right thing to generate HTML/PDFs.

Do note that, for materials intended to add to `doc/pdfs/`, the contents of
their `index.md` (other than the hierarchical information) will **not**
render in the PDF - this is an intentional choice to allow for some
sauclovian-g marked this conversation as resolved.
Show resolved Hide resolved
"HTML-only" content in the front-matter (e.g. code downloads for tutorials).
See [below](#pdf-generation) for information about setting the title of
generated PDFs given this rendering quirk.
2. Create additional `.md` files for your content, organizing them using
`toctree`s as appropriate.
Ideally, for every entry in the top-level `toctree` of your material, there
will be a corresponding `.md` file (or directory of `.md` files, possibly
with its own `index.md` and additional `toctree`s).
This is how we maintain the directory structure / document hierarchy
correspondence.

Note that your documentation doesn't necessarily _need_ its own directory; if
it's a single page, consider adding it as a single `.md` file to the most
appropriate directory, and adding an entry to the corresponding `toctree` (for
some examples of this, see `doc/developer/`).

#### Code examples

It is useful to provide code sample downloads when writing tutorial-style
documentation materials, so readers can easily follow along.

We have implemented a small Sphinx extension, `sphinx-download-dir`, to make it
easier to provide full-directory downloads in your documents.

To use this feature:

1. Create your directory that should be downloadable somewhere in `doc/` (as
long as it's somewhere in the tree, you'll be able to create a download
link).
2. Take note of the directory's location, either relative to `doc/` or relative
to the document where you would like to create a download link (either will
work).
3. Add the link:

```markdown
Check out my cool {download-dir}`download<path/to/dir>`!
```

This will look for `path/to/dir` relative to this document; to look for it
relative to `doc/`, prefix with a `/`
(i.e. ``{download-dir}</path/to/dir>``).

That's it!

#### PDF generation

Some resources should be turned into PDFs stored in `doc/pdfs`.

Fortunately, Sphinx allows for the layout of generated TeX / PDFs to be
controlled at a fairly granular level.
The file `doc/conf.py` attempts to simplify this for our purposes.

In that configuration, there is a variable `pdfs` that holds a reference to a
list of 3-tuples of strings, each of which has the following form:

`(<document root directory name>, <document title>, "howto"|"manual")`

The first entry is the root of the resource, assumed to contain an `index.md`
document defining the `toctree` for the resource.

The second entry is the title as it will render on the PDF cover page.

The third entry essentially determines the top-level layout of the material:
`"howto"` results in sections at the top-level, while `"manual"` results in
chapters.
It's a good idea to play with both to find the right fit for your documentation.

By adding an entry to the `pdfs` list, Sphinx will build a TeX document and
corresonding PDF rooted at the configured directory.
This is indeed how we generate the separate tutorials and user manual, even
though `doc/` is _technically_ one giant document.

If you need to use this feature, consult `doc/conf.py` for additional
documentation (and to see the tutorials/manual example configurations).

## For developers

These notes are primarily for those developers working on the documentation
ecosystem itself.

### Sphinx doesn't _require_ Markdown

Because all of the existing SAW documentation was authored in (variants of)
Markdown, it was convenient to use extensions (i.e. `myst-parser`) to quickly
move the existing work into a Sphinx environment without having to translate to
restructuredText.

This is because Sphinx is a documentation _engine_, capable of handling all
kinds of inputs (and producing all kinds of outputs).
In this way, it is similar to the `pandoc` approach we took previously.

That said, due to this flexibility, it is possible to mix-and-match reST and
Markdown when authoring documentation - Sphinx will take care of properly parsing
and resolving everything.

We **strongly** recommend that you stick with Markdown (and the extensions
provided by MyST) unless strictly necessary when authoring SAW documentation,
for consistency with existing materials and to avoid issues resolving, for
example, heading levels.

### The Python environment

If you are hacking on the documentation build itself (e.g. configuring Sphinx,
playing with new extensions, or even simply upgrading the pinned dependencies in
<scripts/requirements.txt>), you can manually activate the Python virtual
environment with `.venv/bin/activate`, and deactivate it again with
`deactivate`.

This ought not be necessary for most work on documentation.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ @book{Lindholm:1999:JVM:553607
edition = {2nd},
publisher = {Addison-Wesley Longman Publishing Co., Inc.},
address = {Boston, MA, USA},
}
}

@Inproceedings{erkok-matthews-cryptolEqChecking-09,
author = "Levent {Erk\"{o}k} and John Matthews",
Expand Down
Loading
Loading