diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e45f54d..745ec98 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,8 @@ +exclude: > + (?x)( + docs/| + node_modules/ + ) repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.0.1 diff --git a/docs/_assets/style.scss b/docs/_assets/style.scss new file mode 100644 index 0000000..91f95c7 --- /dev/null +++ b/docs/_assets/style.scss @@ -0,0 +1,7 @@ + + +@import "../node_modules/bulma/bulma"; + +a { + color:pink; +} diff --git a/docs/_static/style.css b/docs/_static/style.css new file mode 100644 index 0000000..460ba79 --- /dev/null +++ b/docs/_static/style.css @@ -0,0 +1,3 @@ +@charset "UTF-8"; +/*! bulma.io v0.9.3 | MIT License | github.com/jgthms/bulma */.breadcrumb{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.breadcrumb:not(:last-child){margin-bottom:1.5rem} +/*! minireset.css v0.0.6 | MIT License | github.com/jgthms/minireset.css */*,:after,:before{box-sizing:inherit}@-webkit-keyframes spinAround{0%{transform:rotate(0deg)}to{transform:rotate(359deg)}}@keyframes spinAround{0%{transform:rotate(0deg)}to{transform:rotate(359deg)}}@-webkit-keyframes moveIndeterminate{0%{background-position:200% 0}to{background-position:-200% 0}}@keyframes moveIndeterminate{0%{background-position:200% 0}to{background-position:-200% 0}}.breadcrumb{font-size:1rem;white-space:nowrap}.breadcrumb a{align-items:center;color:#485fc7;display:flex;justify-content:center;padding:0 .75em}.breadcrumb a:hover{color:#363636}.breadcrumb li{align-items:center;display:flex}.breadcrumb li:first-child a{padding-left:0}.breadcrumb li.is-active a{color:#363636;cursor:default;pointer-events:none}.breadcrumb li+li:before{color:#b5b5b5;content:"/"}.breadcrumb ol,.breadcrumb ul{align-items:flex-start;display:flex;flex-wrap:wrap;justify-content:flex-start}.breadcrumb .icon:first-child{margin-right:.5em}.breadcrumb .icon:last-child{margin-left:.5em}.breadcrumb.is-centered ol,.breadcrumb.is-centered ul{justify-content:center}.breadcrumb.is-right ol,.breadcrumb.is-right ul{justify-content:flex-end}.breadcrumb.is-small{font-size:.75rem}.breadcrumb.is-medium{font-size:1.25rem}.breadcrumb.is-large{font-size:1.5rem}.breadcrumb.has-arrow-separator li+li:before{content:"→"}.breadcrumb.has-bullet-separator li+li:before{content:"•"}.breadcrumb.has-dot-separator li+li:before{content:"·"}.breadcrumb.has-succeeds-separator li+li:before{content:"≻"} diff --git a/docs/_templates/home_layout.html b/docs/_templates/home_layout.html new file mode 100644 index 0000000..6ea1eae --- /dev/null +++ b/docs/_templates/home_layout.html @@ -0,0 +1,132 @@ +{# + basic/layout.html + ~~~~~~~~~~~~~~~~~ + + Master layout template for Sphinx themes. + + :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +#} +{%- block doctype -%}{%- if html5_doctype %} + +{%- else %} + +{%- endif %}{%- endblock %} +{%- set reldelim1 = reldelim1 is not defined and ' »' or reldelim1 %} +{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %} +{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and + (sidebars != []) %} +{# URL root should never be #, then all links are fragments #} +{%- if not embedded and docstitle %} + {%- set titlesuffix = " — "|safe + docstitle|e %} +{%- else %} + {%- set titlesuffix = "" %} +{%- endif %} + + +{%- if html_tag %} +{{ html_tag }} +{%- else %} + +{%- endif %} +
+ {%- if not html5_doctype and not skip_ua_compatible %} + + {%- endif %} + {%- if use_meta_charset or html5_doctype %} + + {%- else %} + + {%- endif %} + + {{- metatags }} + {%- block htmltitle %} +
+
+
+
+
+
+# CSSTree
+
+[](https://www.npmjs.com/package/css-tree)
+[](https://travis-ci.org/csstree/csstree)
+[](https://coveralls.io/github/csstree/csstree?branch=master)
+[](https://www.npmjs.com/package/css-tree)
+[](https://twitter.com/csstree)
+
+CSSTree is a tool set for CSS: [fast](https://github.com/postcss/benchmark) detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations. The main goal is to be efficient and W3C specs compliant, with focus on CSS analyzing and source-to-source transforming tasks.
+
+> NOTE: The library isn't in final shape and needs further improvements (e.g. AST format and API are subjects to change in next major versions). However it's stable enough and used by projects like [CSSO](https://github.com/css/csso) (CSS minifier) and [SVGO](https://github.com/svg/svgo) (SVG optimizer) in production.
+
+## Features
+
+- **Detailed parsing with an adjustable level of detail**
+
+ By default CSSTree parses CSS as detailed as possible, i.e. each single logical part is representing with its own AST node (see [AST format](docs/ast.md) for all possible node types). The parsing detail level can be changed through [parser options](docs/parsing.md#parsesource-options), for example, you can disable parsing of selectors or declaration values for component parts.
+
+- **Tolerant to errors by design**
+
+ Parser behaves as [spec says](https://www.w3.org/TR/css-syntax-3/#error-handling): "When errors occur in CSS, the parser attempts to recover gracefully, throwing away only the minimum amount of content before returning to parsing as normal". The only thing the parser departs from the specification is that it doesn't throw away bad content, but wraps it in a special node type (`Raw`) that allows processing it later.
+
+- **Fast and efficient**
+
+ CSSTree is created with focus on performance and effective memory consumption. Therefore it's [one of the fastest CSS parsers](https://github.com/postcss/benchmark) at the moment.
+
+- **Syntax validation**
+
+ The build-in lexer can test CSS against syntaxes defined by W3C. CSSTree uses [mdn/data](https://github.com/mdn/data/) as a basis for lexer's dictionaries and extends it with vendor specific and legacy syntaxes. Lexer can only check the declaration values currently, but this feature will be extended to other parts of the CSS in the future.
+
+## Documentation
+
+- [AST format](docs/ast.md)
+- [Parsing CSS → AST](docs/parsing.md)
+ - [parse(source[, options])](docs/parsing.md#parsesource-options)
+- [Serialization AST → CSS](docs/generate.md)
+ - [generate(ast[, options])](docs/generate.md#generateast-options)
+- [AST traversal](docs/traversal.md)
+ - [walk(ast, options)](docs/traversal.md#walkast-options)
+ - [find(ast, fn)](docs/traversal.md#findast-fn)
+ - [findLast(ast, fn)](docs/traversal.md#findlastast-fn)
+ - [findAll(ast, fn)](docs/traversal.md#findallast-fn)
+- [Utils for AST](docs/utils.md)
+ - [property(name)](docs/utils.md#propertyname)
+ - [keyword(name)](docs/utils.md#keywordname)
+ - [clone(ast)](docs/utils.md#cloneast)
+ - [fromPlainObject(object)](docs/utils.md#fromplainobjectobject)
+ - [toPlainObject(ast)](docs/utils.md#toplainobjectast)
+- [Value Definition Syntax](docs/definition-syntax.md)
+ - [parse(source)](docs/definition-syntax.md#parsesource)
+ - [walk(node, options, context)](docs/definition-syntax.md#walknode-options-context)
+ - [generate(node, options)](docs/definition-syntax.md#generatenode-options)
+ - [AST format](docs/definition-syntax.md#ast-format)
+
+## Tools
+
+* [AST Explorer](https://astexplorer.net/#/gist/244e2fb4da940df52bf0f4b94277db44/e79aff44611020b22cfd9708f3a99ce09b7d67a8) – explore CSSTree AST format with zero setup
+* [CSS syntax reference](https://csstree.github.io/docs/syntax.html)
+* [CSS syntax validator](https://csstree.github.io/docs/validator.html)
+
+## Related projects
+
+* [csstree-validator](https://github.com/csstree/validator) – NPM package to validate CSS
+* [stylelint-csstree-validator](https://github.com/csstree/stylelint-validator) – plugin for stylelint to validate CSS
+* [Grunt plugin](https://github.com/sergejmueller/grunt-csstree-validator)
+* [Gulp plugin](https://github.com/csstree/gulp-csstree)
+* [Sublime plugin](https://github.com/csstree/SublimeLinter-contrib-csstree)
+* [VS Code plugin](https://github.com/csstree/vscode-plugin)
+* [Atom plugin](https://github.com/csstree/atom-plugin)
+
+## Usage
+
+Install with npm:
+
+```
+> npm install css-tree
+```
+
+Basic usage:
+
+```js
+var csstree = require('css-tree');
+
+// parse CSS to AST
+var ast = csstree.parse('.example { world: "!" }');
+
+// traverse AST and modify it
+csstree.walk(ast, function(node) {
+ if (node.type === 'ClassSelector' && node.name === 'example') {
+ node.name = 'hello';
+ }
+});
+
+// generate CSS from AST
+console.log(csstree.generate(ast));
+// .hello{world:"!"}
+```
+
+Syntax matching:
+
+```js
+// parse CSS to AST as a declaration value
+var ast = csstree.parse('red 1px solid', { context: 'value' });
+
+// match to syntax of `border` property
+var matchResult = csstree.lexer.matchProperty('border', ast);
+
+// check first value node is a