Skip to content

Commit dc84d7c

Browse files
ic-768Kevin Goldsmithmattkram
authored
Minor improvements (pyscript#556)
* checkpoint: added some text * checkpoint: added setting up the environment, tips for writing good issues * continuing to fill it out * added more detailed description of the process of creating a change and some other cleanup. * added a getting started section and cleaned up the grammar. This ready for the PR now * forgot to add the new section to the TOC * Minor fixes Co-authored-by: Kevin Goldsmith <kgoldsmith@anaconda.com> Co-authored-by: Matt Kramer <mkramer@anaconda.com>
1 parent fcaa573 commit dc84d7c

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ take a look at the general contributing guidelines for the PyScript project. You
1111

1212
## Documentation Principles
1313

14-
The PyScript documentation is based on a documentation framework called [Diátaxis](https://diataxis.fr/). This framework helps to solve the problem of structure in technical documentation and identifies four modes of documentation - **tutorials, how-to guides, technical reference and explanation**. Each one of these modes answers to a different user need, fulfils a different purpose and requires a different approach to its creation.
14+
The PyScript documentation is based on a documentation framework called [Diátaxis](https://diataxis.fr/). This framework helps to solve the problem of structure in technical documentation and identifies four modes of documentation - **tutorials, how-to guides, technical reference and explanation**. Each one of these modes answers to a different user need, fulfills a different purpose and requires a different approach to its creation.
1515

1616
The picture below gives a good visual representation of that separation of concerns:
1717

@@ -24,4 +24,4 @@ So, please keep that in mind when contributing to the project documentation. For
2424
The `docs` directory in the pyscript repository contains a
2525
[Sphinx](https://www.sphinx-doc.org/) documentation project. Sphinx is a system
2626
that takes plaintext files containing documentation written in Markdown, along with
27-
and static files like templates and themes, to build the static end result.
27+
static files like templates and themes, to build the static end result.

pyscriptjs/src/components/base.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,8 @@ export class BaseEvalElement extends HTMLElement {
152152
this.outputElement.style.display = 'block';
153153
}
154154

155-
if (is_async) {
156-
await pyodide.runPythonAsync(`output_manager.revert()`);
157-
} else {
158-
await pyodide.runPython(`output_manager.revert()`);
159-
}
155+
is_async ? await pyodide.runPythonAsync(`output_manager.revert()`)
156+
: await pyodide.runPython(`output_manager.revert()`);
160157

161158
// check if this REPL contains errors, delete them and remove error classes
162159
const errorElements = document.querySelectorAll(`div[id^='${this.errorElement.id}'][error]`);
@@ -189,11 +186,10 @@ export class BaseEvalElement extends HTMLElement {
189186
} // end evaluate
190187

191188
async eval(source: string): Promise<void> {
192-
let output;
193189
const pyodide = runtime;
194190

195191
try {
196-
output = await pyodide.runPythonAsync(source);
192+
const output = await pyodide.runPythonAsync(source);
197193
if (output !== undefined) {
198194
console.log(output);
199195
}
@@ -268,10 +264,9 @@ function createWidget(name: string, code: string, klass: string) {
268264
}
269265

270266
async eval(source: string): Promise<void> {
271-
let output;
272267
const pyodide = runtime;
273268
try {
274-
output = await pyodide.runPythonAsync(source);
269+
const output = await pyodide.runPythonAsync(source);
275270
this.proxyClass = pyodide.globals.get(this.klass);
276271
if (output !== undefined) {
277272
console.log(output);
@@ -281,7 +276,6 @@ function createWidget(name: string, code: string, klass: string) {
281276
}
282277
}
283278
}
284-
const xPyWidget = customElements.define(name, CustomWidget);
285279
}
286280

287281
export class PyWidget extends HTMLElement {
@@ -361,16 +355,14 @@ export class PyWidget extends HTMLElement {
361355
}
362356

363357
async getSourceFromFile(s: string): Promise<string> {
364-
const pyodide = runtime;
365358
const response = await fetch(s);
366359
return await response.text();
367360
}
368361

369362
async eval(source: string): Promise<void> {
370-
let output;
371363
const pyodide = runtime;
372364
try {
373-
output = await pyodide.runPythonAsync(source);
365+
const output = await pyodide.runPythonAsync(source);
374366
if (output !== undefined) {
375367
console.log(output);
376368
}

0 commit comments

Comments
 (0)