d33953037e
* Create aryaprabhudesai.md (#2681) * Update _install.jade (#2688) Typo fix: "models" -> "model" * Add FAC to spacy.explain (resolves #2706) * Remove docstrings for deprecated arguments (see #2703) * When calling getoption() in conftest.py, pass a default option (#2709) * When calling getoption() in conftest.py, pass a default option This is necessary to allow testing an installed spacy by running: pytest --pyargs spacy * Add contributor agreement * update bengali token rules for hyphen and digits (#2731) * Less norm computations in token similarity (#2730) * Less norm computations in token similarity * Contributor agreement * Remove ')' for clarity (#2737) Sorry, don't mean to be nitpicky, I just noticed this when going through the CLI and thought it was a quick fix. That said, if this was intention than please let me know. * added contributor agreement for mbkupfer (#2738) * Basic support for Telugu language (#2751) * Lex _attrs for polish language (#2750) * Signed spaCy contributor agreement * Added polish version of english lex_attrs * Introduces a bulk merge function, in order to solve issue #653 (#2696) * Fix comment * Introduce bulk merge to increase performance on many span merges * Sign contributor agreement * Implement pull request suggestions * Describe converters more explicitly (see #2643) * Add multi-threading note to Language.pipe (resolves #2582) [ci skip] * Fix formatting * Fix dependency scheme docs (closes #2705) [ci skip] * Don't set stop word in example (closes #2657) [ci skip] * Add words to portuguese language _num_words (#2759) * Add words to portuguese language _num_words * Add words to portuguese language _num_words * Update Indonesian model (#2752) * adding e-KTP in tokenizer exceptions list * add exception token * removing lines with containing space as it won't matter since we use .split() method in the end, added new tokens in exception * add tokenizer exceptions list * combining base_norms with norm_exceptions * adding norm_exception * fix double key in lemmatizer * remove unused import on punctuation.py * reformat stop_words to reduce number of lines, improve readibility * updating tokenizer exception * implement is_currency for lang/id * adding orth_first_upper in tokenizer_exceptions * update the norm_exception list * remove bunch of abbreviations * adding contributors file * Fixed spaCy+Keras example (#2763) * bug fixes in keras example * created contributor agreement * Adding French hyphenated first name (#2786) * Fix typo (closes #2784) * Fix typo (#2795) [ci skip] Fixed typo on line 6 "regcognizer --> recognizer" * Adding basic support for Sinhala language. (#2788) * adding Sinhala language package, stop words, examples and lex_attrs. * Adding contributor agreement * Updating contributor agreement * Also include lowercase norm exceptions * Fix error (#2802) * Fix error ValueError: cannot resize an array that references or is referenced by another array in this way. Use the resize function * added spaCy Contributor Agreement * Add charlax's contributor agreement (#2805) * agreement of contributor, may I introduce a tiny pl languge contribution (#2799) * Contributors agreement * Contributors agreement * Contributors agreement * Add jupyter=True to displacy.render in documentation (#2806) * Revert "Also include lowercase norm exceptions" This reverts commit |
||
---|---|---|
.. | ||
_includes | ||
api | ||
assets | ||
models | ||
universe | ||
usage | ||
_data.json | ||
_harp.json | ||
_layout.jade | ||
404.jade | ||
index.jade | ||
package.json | ||
README.md | ||
robots.txt.jade | ||
styleguide.jade |
spacy.io website and docs
The spacy.io website is implemented in Jade (aka Pug), and is built or served by Harp. Jade is an extensible templating language with a readable syntax, that compiles to HTML. The website source makes extensive use of Jade mixins, so that the design system is abstracted away from the content you're writing. You can read more about our approach in our blog post, "Rebuilding a Website with Modular Markup".
Viewing the site locally
sudo npm install --global harp
git clone https://github.com/explosion/spaCy
cd spaCy/website
harp server
This will serve the site on http://localhost:9000.
Making changes to the site
The docs can always use another example or more detail, and they should always be up to date and not misleading. If you see something, say something – we always appreciate a pull request. To quickly find the correct file to edit, simply click on the "Suggest edits" button at the bottom of a page.
File structure
While all page content lives in the .jade
files, article meta (page titles, sidebars etc.) is stored as JSON. Each folder contains a _data.json
with all required meta for its files.
Markup language and conventions
Jade/Pug is a whitespace-sensitive markup language that compiles to HTML. Indentation is used to nest elements, and for template logic, like if
/else
or for
, mainly used to iterate over objects and arrays in the meta data. It also allows inline JavaScript expressions.
For an overview of Harp and Jade, see this blog post. For more info on the Jade/Pug syntax, check out their documentation.
In the spacy.io source, we use 4 spaces to indent and hard-wrap at 80 characters.
p This is a very short paragraph. It stays inline.
p
| This is a much longer paragraph. It's hard-wrapped at 80 characters to
| make it easier to read on GitHub and in editors that do not have soft
| wrapping enabled. To prevent Jade from interpreting each line as a new
| element, it's prefixed with a pipe and two spaces. This ensures that no
| spaces are dropped – for example, if your editor strips out trailing
| whitespace by default. Inline links are added using the inline syntax,
| like this: #[+a("https://google.com") Google].
Note that for external links, +a("...")
is used instead of a(href="...")
– it's a mixin that takes care of adding all required attributes. If possible, always use a mixin instead of regular HTML elements. The only plain HTML elements we use are:
Element | Description |
---|---|
p |
paragraphs |
code |
inline code |
em |
italicized text |
strong |
bold text |
Mixins
Each file includes a collection of custom mixins that make it easier to add content components – no HTML or class names required.
For example:
//- Bulleted list
+list
+item This is a list item.
+item This is another list item.
//- Table with header
+table([ "Header one", "Header two" ])
+row
+cell Table cell
+cell Another one
+row
+cell And one more.
+cell And the last one.
//- Headlines with optional permalinks
+h(2, "link-id") Headline 2 with link to #link-id
Code blocks are implemented using +code
or +aside-code
(to display them in the right sidebar). A .
is added after the mixin call to preserve whitespace:
+code("This is a label").
import spacy
en_nlp = spacy.load('en')
en_doc = en_nlp(u'Hello, world. Here are two sentences.')
You can find the documentation for the available mixins in _includes/_mixins.jade
.
Helpers for linking to content
Aside from the +a()
mixin, there are three other helpers to make linking to content more convenient.
Linking to GitHub
Since GitHub links can be long and tricky, you can use the gh()
function to generate them automatically for spaCy and all repositories owned by explosion:
// Syntax: gh(repo, [file], [branch])
gh("spaCy", "spacy/matcher.pyx")
// https://github.com/explosion/spaCy/blob/master/spacy/matcher.pyx
Linking to source
+src()
generates a link with a little source icon to indicate it's linking to a code source. Ideally, it's used in combination with gh()
:
+src(gh("spaCy", "spacy/matcher.pyx")) matcher.pxy
Linking to API reference
+api()
generates a link to a page in the API docs, with an added icon. It should only be used across the workflows in the usage section, and only on the first mention of the respective class.
It takes the slug of an API page as the argument. You can also use anchors to link to specific sections – they're usually the method or property names.
+api("tokenizer") #[code Tokenizer]
+api("doc#similarity") #[code Doc.similarity()]
Most common causes of compile errors
Problem | Fix |
---|---|
JSON formatting errors | make sure last elements of objects don't end with commas and/or use a JSON linter |
unescaped characters like < or > and sometimes ' in inline elements |
replace with encoded version: < , > etc. |
"Cannot read property 'call' of undefined" / "foo is not a function" | make sure mixin names are spelled correctly and mixins file is included with the correct path |
"no closing bracket found" | make sure inline elements end with a ] , like #[code spacy.load('en')] and for nested inline elements, make sure they're all on the same line and contain spaces between them (bad: #[+api("doc")#[code Doc]] ) |
If Harp fails and throws a Jade error, don't take the reported line number at face value – it's often wrong, as the page is compiled from templates and several files.