Skip to content

Commit a3e9d5a

Browse files
committed
Add docs to readme
1 parent 5e7386f commit a3e9d5a

File tree

2 files changed

+173
-147
lines changed

2 files changed

+173
-147
lines changed

.github/workflows/release.yml

Lines changed: 147 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -3,166 +3,166 @@ on:
33
workflow_dispatch:
44

55
jobs:
6-
# build:
7-
# strategy:
8-
# fail-fast: false
9-
# matrix:
10-
# include:
11-
# # Windows
12-
# - os: windows-latest
13-
# target: x86_64-pc-windows-msvc
14-
# # Mac OS
15-
# - os: macos-latest
16-
# target: x86_64-apple-darwin
17-
# strip: strip -x # Must use -x on macOS. This produces larger results on linux.
6+
build:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
include:
11+
# Windows
12+
- os: windows-latest
13+
target: x86_64-pc-windows-msvc
14+
# Mac OS
15+
- os: macos-latest
16+
target: x86_64-apple-darwin
17+
strip: strip -x # Must use -x on macOS. This produces larger results on linux.
1818

19-
# name: build-${{ matrix.target }}
20-
# runs-on: ${{ matrix.os }}
21-
# steps:
22-
# - uses: actions/checkout@v2
23-
# - name: Install Node.JS
24-
# uses: actions/setup-node@v2
25-
# with:
26-
# node-version: 14
27-
# - name: Install Rust
28-
# uses: actions-rs/toolchain@v1
29-
# with:
30-
# toolchain: stable
31-
# profile: minimal
32-
# override: true
19+
name: build-${{ matrix.target }}
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Install Node.JS
24+
uses: actions/setup-node@v2
25+
with:
26+
node-version: 14
27+
- name: Install Rust
28+
uses: actions-rs/toolchain@v1
29+
with:
30+
toolchain: stable
31+
profile: minimal
32+
override: true
3333

34-
# - name: Setup rust target
35-
# run: rustup target add ${{ matrix.target }}
34+
- name: Setup rust target
35+
run: rustup target add ${{ matrix.target }}
3636

37-
# - uses: bahmutov/npm-install@v1.1.0
38-
# - name: Build release
39-
# run: yarn build-release
40-
# env:
41-
# RUST_TARGET: ${{ matrix.target }}
42-
# - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
43-
# if: ${{ matrix.strip }}
44-
# run: ${{ matrix.strip }} *.node
45-
# - name: Upload artifacts
46-
# uses: actions/upload-artifact@v2
47-
# with:
48-
# name: bindings-${{ matrix.target }}
49-
# path: '*.node'
37+
- uses: bahmutov/npm-install@v1.1.0
38+
- name: Build release
39+
run: yarn build-release
40+
env:
41+
RUST_TARGET: ${{ matrix.target }}
42+
- name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
43+
if: ${{ matrix.strip }}
44+
run: ${{ matrix.strip }} *.node
45+
- name: Upload artifacts
46+
uses: actions/upload-artifact@v2
47+
with:
48+
name: bindings-${{ matrix.target }}
49+
path: '*.node'
5050

51-
# build-apple-silicon:
52-
# name: build-apple-silicon
53-
# runs-on: macos-latest
54-
# steps:
55-
# - uses: actions/checkout@v2
56-
# - name: Install Node.JS
57-
# uses: actions/setup-node@v2
58-
# with:
59-
# node-version: 14
60-
# - name: Install Rust
61-
# uses: actions-rs/toolchain@v1
62-
# with:
63-
# toolchain: stable
64-
# profile: minimal
65-
# override: true
51+
build-apple-silicon:
52+
name: build-apple-silicon
53+
runs-on: macos-latest
54+
steps:
55+
- uses: actions/checkout@v2
56+
- name: Install Node.JS
57+
uses: actions/setup-node@v2
58+
with:
59+
node-version: 14
60+
- name: Install Rust
61+
uses: actions-rs/toolchain@v1
62+
with:
63+
toolchain: stable
64+
profile: minimal
65+
override: true
6666

67-
# - name: Setup rust target
68-
# run: rustup target add aarch64-apple-darwin
67+
- name: Setup rust target
68+
run: rustup target add aarch64-apple-darwin
6969

70-
# - uses: bahmutov/npm-install@v1.1.0
71-
# - name: Build release
72-
# run: yarn build-release
73-
# env:
74-
# RUST_TARGET: aarch64-apple-darwin
75-
# JEMALLOC_SYS_WITH_LG_PAGE: 14
76-
# - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
77-
# run: strip -x *.node
78-
# - name: Upload artifacts
79-
# uses: actions/upload-artifact@v2
80-
# with:
81-
# name: bindings-aarch64-apple-darwin
82-
# path: '*.node'
70+
- uses: bahmutov/npm-install@v1.1.0
71+
- name: Build release
72+
run: yarn build-release
73+
env:
74+
RUST_TARGET: aarch64-apple-darwin
75+
JEMALLOC_SYS_WITH_LG_PAGE: 14
76+
- name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
77+
run: strip -x *.node
78+
- name: Upload artifacts
79+
uses: actions/upload-artifact@v2
80+
with:
81+
name: bindings-aarch64-apple-darwin
82+
path: '*.node'
8383

84-
# build-linux:
85-
# strategy:
86-
# fail-fast: false
87-
# matrix:
88-
# include:
89-
# - target: x86_64-unknown-linux-gnu
90-
# strip: strip
91-
# image: docker.io/centos/nodejs-12-centos7
92-
# setup: npm install --global yarn@1
93-
# - target: aarch64-unknown-linux-gnu
94-
# strip: aarch64-linux-gnu-strip
95-
# image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
96-
# - target: armv7-unknown-linux-gnueabihf
97-
# strip: arm-linux-gnueabihf-strip
98-
# image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
99-
# setup: apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
100-
# - target: aarch64-unknown-linux-musl
101-
# image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
102-
# strip: aarch64-linux-musl-strip
103-
# - target: x86_64-unknown-linux-musl
104-
# image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
105-
# strip: strip
84+
build-linux:
85+
strategy:
86+
fail-fast: false
87+
matrix:
88+
include:
89+
- target: x86_64-unknown-linux-gnu
90+
strip: strip
91+
image: docker.io/centos/nodejs-12-centos7
92+
setup: npm install --global yarn@1
93+
- target: aarch64-unknown-linux-gnu
94+
strip: aarch64-linux-gnu-strip
95+
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
96+
- target: armv7-unknown-linux-gnueabihf
97+
strip: arm-linux-gnueabihf-strip
98+
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
99+
setup: apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
100+
- target: aarch64-unknown-linux-musl
101+
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
102+
strip: aarch64-linux-musl-strip
103+
- target: x86_64-unknown-linux-musl
104+
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
105+
strip: strip
106106

107-
# name: build-${{ matrix.target }}
108-
# runs-on: ubuntu-latest
109-
# container:
110-
# image: ${{ matrix.image }}
107+
name: build-${{ matrix.target }}
108+
runs-on: ubuntu-latest
109+
container:
110+
image: ${{ matrix.image }}
111111

112-
# steps:
113-
# - uses: actions/checkout@v2
114-
# - name: Install Node.JS
115-
# uses: actions/setup-node@v2
116-
# with:
117-
# node-version: 14
118-
# - name: Install Rust
119-
# uses: actions-rs/toolchain@v1
120-
# with:
121-
# toolchain: stable
122-
# profile: minimal
123-
# override: true
112+
steps:
113+
- uses: actions/checkout@v2
114+
- name: Install Node.JS
115+
uses: actions/setup-node@v2
116+
with:
117+
node-version: 14
118+
- name: Install Rust
119+
uses: actions-rs/toolchain@v1
120+
with:
121+
toolchain: stable
122+
profile: minimal
123+
override: true
124124

125-
# - name: Setup cross compile toolchain
126-
# if: ${{ matrix.setup }}
127-
# run: ${{ matrix.setup }}
125+
- name: Setup cross compile toolchain
126+
if: ${{ matrix.setup }}
127+
run: ${{ matrix.setup }}
128128

129-
# - name: Setup rust target
130-
# run: rustup target add ${{ matrix.target }}
129+
- name: Setup rust target
130+
run: rustup target add ${{ matrix.target }}
131131

132-
# - uses: bahmutov/npm-install@v1.1.0
133-
# - name: Build release
134-
# run: yarn build-release
135-
# env:
136-
# RUST_TARGET: ${{ matrix.target }}
137-
# - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
138-
# if: ${{ matrix.strip }}
139-
# run: ${{ matrix.strip }} *.node
140-
# - name: Upload artifacts
141-
# uses: actions/upload-artifact@v2
142-
# with:
143-
# name: bindings-${{ matrix.target }}
144-
# path: '*.node'
132+
- uses: bahmutov/npm-install@v1.1.0
133+
- name: Build release
134+
run: yarn build-release
135+
env:
136+
RUST_TARGET: ${{ matrix.target }}
137+
- name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
138+
if: ${{ matrix.strip }}
139+
run: ${{ matrix.strip }} *.node
140+
- name: Upload artifacts
141+
uses: actions/upload-artifact@v2
142+
with:
143+
name: bindings-${{ matrix.target }}
144+
path: '*.node'
145145

146-
# release:
147-
# runs-on: ubuntu-latest
148-
# name: Build and release
149-
# needs:
150-
# - build
151-
# - build-linux
152-
# - build-apple-silicon
153-
# steps:
154-
# - uses: actions/checkout@v1
155-
# - uses: bahmutov/npm-install@v1.1.0
156-
# - name: Download artifacts
157-
# uses: actions/download-artifact@v2
158-
# with:
159-
# path: artifacts
160-
# - name: Move artifacts
161-
# run: cp artifacts/*/*.node .
162-
# - run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
163-
# env:
164-
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
165-
# - run: npm publish
146+
release:
147+
runs-on: ubuntu-latest
148+
name: Build and release
149+
needs:
150+
- build
151+
- build-linux
152+
- build-apple-silicon
153+
steps:
154+
- uses: actions/checkout@v1
155+
- uses: bahmutov/npm-install@v1.1.0
156+
- name: Download artifacts
157+
uses: actions/download-artifact@v2
158+
with:
159+
path: artifacts
160+
- name: Move artifacts
161+
run: cp artifacts/*/*.node .
162+
- run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
163+
env:
164+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
165+
- run: npm publish
166166

167167
release-crates:
168168
runs-on: ubuntu-latest

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,32 @@ A WIP CSS parser, transformer, and minifier written in Rust.
3232
- Multi-value `display` property (e.g. `inline flex`)
3333
- **CSS modules** – TODO
3434

35+
## Documentation
36+
37+
### From JavaScript
38+
39+
More docs to come, but here is a simple example:
40+
41+
```js
42+
const css = require('@parcel/css');
43+
44+
let {code, map} = css.transform({
45+
filename: 'style.css',
46+
code: Buffer.from('.foo { color: red }'),
47+
minify: true,
48+
source_map: true,
49+
targets: {
50+
// Semver versions are represented using a single 24-bit number, with one component per byte.
51+
// e.g. to represent 13.2.0, the following could be used.
52+
safari: (13 << 16) | (2 << 8)
53+
}
54+
});
55+
```
56+
57+
### From Rust
58+
59+
See the Rust API docs on [docs.rs](https://docs.rs/parcel_css).
60+
3561
## Benchmarks
3662

3763
```

0 commit comments

Comments
 (0)