8000 Add a usage section to readme · codemirror/lang-python@fec0c16 · GitHub
[go: up one dir, main page]

Skip to content

Commit fec0c16

Browse files
committed
Add a usage section to readme
1 parent 83ed6b3 commit fec0c16

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

README.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,26 @@ we have a [code of
1919
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
2020
to communication around the project.
2121

22+
## Usage
23+
24+
```javascript
25+
import {EditorView, basicSetup} from "codemirror"
26+
import {python} from "@codemirror/lang-python"
27+
28+
const view = new EditorView({
29+
parent: document.body,
30+
doc: `print("Hello world")`,
31+
extensions: [basicSetup, python()]
32+
})
33+
```
34+
2235
# API Reference
2336

2437
<dl>
25-
<dt id="user-content-globalcompletion">
26-
<code><strong><a href="#user-content-globalcompletion">globalCompletion</a></strong>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionSource">CompletionSource</a></code></dt>
27-
28-
<dd><p>Autocompletion for built-in Python globals and keywords.</p>
29-
</dd>
30-
<dt id="user-content-localcompletionsource">
31-
<code><strong><a href="#user-content-localcompletionsource">localCompletionSource</a></strong>(<a id="user-content-localcompletionsource^context" href="#user-content-localcompletionsource^context">context</a>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionContext">CompletionContext</a>) → <a href="https://codemirror.net/docs/ref#autocomplete.CompletionResult">CompletionResult</a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a></code></dt>
38+
<dt id="user-content-python">
39+
<code><strong><a href="#user-content-python">python</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
3240

33-
<dd><p>Completion source that looks up locally defined names in
34-
Python code.</p>
41+
<dd><p>Python language support.</p>
3542
</dd>
3643
<dt id="user-content-pythonlanguage">
3744
<code><strong><a href="#user-content-pythonlanguage">pythonLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
@@ -40,9 +47,15 @@ Python code.</p>
4047
parser</a>, extended with
4148
highlighting and indentation information.</p>
4249
</dd>
43-
<dt id="user-content-python">
44-
<code><strong><a href="#user-content-python">python</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
50+
<dt id="user-content-globalcompletion">
51+
<code><strong><a href="#user-content-globalcompletion">globalCompletion</a></strong>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionSource">CompletionSource</a></code></dt>
4552

46-
<dd><p>Python language support.</p>
53+
<dd><p>Autocompletion for built-in Python globals and keywords.</p>
54+
</dd>
55+
<dt id="user-content-localcompletionsource">
56+
<code><strong><a href="#user-content-localcompletionsource">localCompletionSource</a></strong>(<a id="user-content-localcompletionsource^context" href="#user-content-localcompletionsource^context">context</a>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionContext">CompletionContext</a>) → <a href="https://codemirror.net/docs/ref#autocomplete.CompletionResult">CompletionResult</a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a></code></dt>
57+
58+
<dd><p>Completion source that looks up locally defined names in
59+
Python code.</p>
4760
</dd>
48-
</dl>
61+
</dl>

src/README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,25 @@ we have a [code of
1919
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
2020
to communication around the project.
2121

22+
## Usage
23+
24+
```javascript
25+
import {EditorView, basicSetup} from "codemirror"
26+
import {python} from "@codemirror/lang-python"
27+
28+
const view = new EditorView({
29+
parent: document.body,
30+
doc: `print("Hello world")`,
31+
extensions: [basicSetup, python()]
32+
})
33+
```
34+
2235
# API Reference
2336

2437
@python
2538

26-
@pythonLanguage
39+
@pythonLanguage
40+
41+
@globalCompletion
42+
43+
@localCompletionSource

0 commit comments

Comments
 (0)
0