Skip to content

Commit

Permalink
Merge branch 'main' into remove-ast-children-field
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed May 11, 2022
2 parents a82da0f + 199e9c6 commit ee905ac
Show file tree
Hide file tree
Showing 15 changed files with 281 additions and 414 deletions.
45 changes: 45 additions & 0 deletions .github/gen_readme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env node

const fs = require("fs");
const Handlebars = require("handlebars");
const path = require("path");

const slurp = (p) => fs.readFileSync(p).toString();
const example = (p) => slurp(path.join("packages/examples/src", p));

const sub = "tree";
const sty = "venn";

const { trios, domains, styles, substances } = JSON.parse(
example("registry.json")
);

const matching = trios.filter(
({ substance, style }) => substance === sub && style === sty
);
if (matching.length !== 1) {
throw Error(`expected exactly one matching trio, got ${matching.length}`);
}
const [{ substance, style, domain, variation }] = matching;

const dslURI = domains[domain].URI;
const subURI = substances[substance].URI;
const styURI = styles[style].URI;

for (const name of ["domain", "substance", "style"]) {
Handlebars.registerPartial(name, `{{{${name}}}}`);
}

fs.writeFileSync(
"README.md",
Handlebars.compile(slurp(".github/readme_template.hbs"))({
svg: `diagrams/${sub}-${sty}.svg`,
variation,
dsl: path.basename(dslURI),
sub: path.basename(subURI),
sty: path.basename(styURI),
domain: example(dslURI),
substance: example(subURI),
style: example(styURI),
})
);
45 changes: 45 additions & 0 deletions .github/readme_template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Penrose [![Build](https://github.com/penrose/penrose/actions/workflows/build.yml/badge.svg)](https://github.com/penrose/penrose/actions/workflows/build.yml) [![codecov](https://codecov.io/gh/penrose/penrose/branch/main/graph/badge.svg?token=opGTmY4rkK)](https://codecov.io/gh/penrose/penrose) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![license](https://img.shields.io/github/license/penrose/penrose)](LICENSE) [![Twitter: @UsePenrose](https://img.shields.io/twitter/follow/UsePenrose?style=social)](https://twitter.com/UsePenrose)

[Penrose](https://penrose.cs.cmu.edu/) is a platform that enables people to
**create beautiful diagrams just by typing mathematical notation in plain
text.** The goal is to make it easy for non-experts to create and explore
high-quality diagrams and provide deeper insight into challenging technical
concepts. We aim to democratize the process of creating visual intuition.

Check out our [SIGGRAPH '20 paper](https://penrose.cs.cmu.edu/siggraph20) and
[video](https://vimeo.com/416822487) on Penrose!

## Usage

You can [try Penrose in your browser](https://penrose.cs.cmu.edu/try/) without
any installation. For a more detailed step-by-step introduction, check out our
[tutorials](https://penrose.cs.cmu.edu/docs/tutorial/welcome). Or, for more
reference-style information, take a look at our
[documentation](https://penrose.cs.cmu.edu/docs/ref/).

## Example

Here's a simple Penrose visualization in the domain of set theory.

<img src="{{svg}}" width=500>

It's specified by the following trio of Domain, Substance, and Style programs
(with variation `{{variation}}`):

- `{{dsl}}`:

```
{{> domain }}
```

- `{{sub}}`:

```
{{> substance }}
```

- `{{sty}}`:

```
{{> style }}
```
18 changes: 14 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
name: diagrams
path: packages/automator/out/
- name: Copy generated diagrams into diagrams/
- name: Check that the generated diagrams/ are all up to date
run: |
rm -r diagrams/
mkdir diagrams/
Expand All @@ -35,9 +35,7 @@ jobs:
name=${dir%/output.svg}
cp "$filename" "diagrams/$name.svg"
done
- name: Ensure no generated diagrams have changed
run: |
"$GITHUB_WORKSPACE/.github/report_git_status.sh"
.github/report_git_status.sh
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -92,6 +90,18 @@ jobs:
- name: Lint
run: yarn lint

readme:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install packages
uses: ./.github/actions/packages
- name: Check that the generated README is up to date
run: |
.github/gen_readme.js
.github/report_git_status.sh
storybook:
runs-on: ubuntu-latest
defaults:
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/*.hbs
**/build/
**/coverage/
**/dist/
Expand All @@ -14,3 +15,4 @@ packages/core/src/parser/SubstanceParser.ts
packages/core/src/renderer/not_found.json
packages/docs-site/.docusaurus/
packages/roger/oclif.manifest.json
README.md
133 changes: 81 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,100 @@
# Penrose [![Build](https://github.com/penrose/penrose/actions/workflows/build.yml/badge.svg)](https://github.com/penrose/penrose/actions/workflows/build.yml) [![codecov](https://codecov.io/gh/penrose/penrose/branch/main/graph/badge.svg?token=opGTmY4rkK)](https://codecov.io/gh/penrose/penrose) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![license](https://img.shields.io/github/license/penrose/penrose)](LICENSE) [![Twitter: @UsePenrose](https://img.shields.io/twitter/follow/UsePenrose?style=social)](https://twitter.com/UsePenrose)

**Penrose is an early-stage system that is still in development.** Our system is not ready for contributions or public use yet, but hopefully will be soon. Send us an email if you're interested in collaborating.
[Penrose](https://penrose.cs.cmu.edu/) is a platform that enables people to
**create beautiful diagrams just by typing mathematical notation in plain
text.** The goal is to make it easy for non-experts to create and explore
high-quality diagrams and provide deeper insight into challenging technical
concepts. We aim to democratize the process of creating visual intuition.

- See [the site](http://www.penrose.ink/) for more information and examples.
- See the [wiki](https://github.com/penrose/penrose/wiki) for more system-specific information on building, running, testing, and debugging the system.
- For even more documentation, see Nimo Ni's [README](https://github.com/wodeni/notes-public/blob/master/penrose/archive/ramp-down.md).
Check out our [SIGGRAPH '20 paper](https://penrose.cs.cmu.edu/siggraph20) and
[video](https://vimeo.com/416822487) on Penrose!

### Example
## Usage

You can [try Penrose in your browser](https://penrose.cs.cmu.edu/try/) without
any installation. For a more detailed step-by-step introduction, check out our
[tutorials](https://penrose.cs.cmu.edu/docs/tutorial/welcome). Or, for more
reference-style information, take a look at our
[documentation](https://penrose.cs.cmu.edu/docs/ref/).

## Example

Here's a simple Penrose visualization in the domain of set theory.

<img src="https://i.imgur.com/3JHZeaX.png" width=300>
<img src="diagrams/tree-venn.svg" width=500>

It's specified by the following Substance and Style programs.
It's specified by the following trio of Domain, Substance, and Style programs
(with variation `CasalViper643`):

- `setTheory.dsl`:

- `tree.sub`
```
Set A
Set B
Set C
Set D
Set E
Set F
Set G
Subset B A
Subset C A
Subset D B
Subset E B
Subset F C
Subset G C
NoIntersect E D
NoIntersect F G
NoIntersect B C
type Set
predicate Not(Prop p1)
predicate Intersecting(Set s1, Set s2)
predicate IsSubset(Set s1, Set s2)
```
- `venn.sty`

- `tree.sub`:

```
Set x {
shape = Circle { }
constraint contains(x, x.label)
}
Set A, B, C, D, E, F, G
IsSubset(B, A)
IsSubset(C, A)
IsSubset(D, B)
IsSubset(E, B)
IsSubset(F, C)
IsSubset(G, C)
Not(Intersecting(E, D))
Not(Intersecting(F, G))
Not(Intersecting(B, C))
AutoLabel All
```

Intersect x y {
constraint overlapping(x, y)
constraint disjoint(y.label, x)
constraint disjoint(x.label, y)
}
- `venn.sty`:

NoIntersect x y {
constraint nonOverlapping(x, y)
```
canvas {
width = 800
height = 700
}
Subset x y {
constraint contains(y, x)
constraint smallerThan(x, y)
constraint disjoint(y.label, x)
forall Set x {
x.icon = Circle {
strokeWidth : 0
}
x.text = Equation {
string : x.label
fontSize : "25px"
}
ensure contains(x.icon, x.text)
encourage sameCenter(x.text, x.icon)
x.textLayering = x.text above x.icon
}
NoSubset x y {
objective repel(x, y)
constraint disjoint(x, y)
constraint disjoint(y.label, x)
constraint disjoint(x.label, y)
constraint nonOverlapping(x, y)
forall Set x; Set y
where IsSubset(x, y) {
ensure smallerThan(x.icon, y.icon)
ensure disjoint(y.text, x.icon, 10)
ensure contains(y.icon, x.icon, 5)
x.icon above y.icon
}
forall Set x; Set y
where Not(Intersecting(x, y)) {
ensure disjoint(x.icon, y.icon)
}
forall Set x; Set y
where Intersecting(x, y) {
ensure overlapping(x.icon, y.icon)
ensure disjoint(y.text, x.icon)
ensure disjoint(x.text, y.icon)
}
```

Here's how the optimization looks live in the UI.

<img src="https://i.imgur.com/Q27Xgbn.gif" width=500>

0 comments on commit ee905ac

Please sign in to comment.