Skip to content

Releases: nalgeon/codapi-js

0.19.8

18 Aug 14:26
Compare
Choose a tag to compare

Disable spell checking for editor = basic.

0.19.7

16 May 09:40
Compare
Choose a tag to compare

Fixes #29 (line breaks in Docusaurus in read-only mode).

0.19.6

13 May 16:45
Compare
Choose a tag to compare

Fixes #26, courtesy of @jonasb.

0.19.5

20 Apr 12:11
Compare
Choose a tag to compare

Even more fixes for Docusaurus code editing (see #22).

0.19.4

18 Apr 14:58
Compare
Choose a tag to compare

Fixed Docusaurus code editing regression introduced in 0.14.0 (see #22).

0.19.3

18 Apr 00:15
Compare
Choose a tag to compare

Fixed depends-on ordering for even more complex dependencies like this:

<pre><code>print("init")</code></pre>
<codapi-snippet id="init" editor="basic">
</codapi-snippet>

<pre><code>print("step a")</code></pre>
<codapi-snippet id="a" editor="basic">
</codapi-snippet>

<pre><code>print("step b")</code></pre>
<codapi-snippet id="b" editor="basic" depends-on="a">
</codapi-snippet>

<pre><code>print("main")</code></pre>
<codapi-snippet id="main" sandbox="python" editor="basic" depends-on="init b">
</codapi-snippet>

Which results in the following output:

init
step a
step b
main

0.19.2

17 Apr 07:05
Compare
Choose a tag to compare

Fixed depends-on ordering for non-linear dependencies like this:

<pre><code>package main</code></pre>
<codapi-snippet id="package" editor="basic">
</codapi-snippet>

<pre><code>import "fmt"</code></pre>
<codapi-snippet id="import" editor="basic">
</codapi-snippet>

<pre><code>func main() { fmt.Println("hello") }</code></pre>
<codapi-snippet sandbox="go" editor="basic" depends-on="package import">
</codapi-snippet>

Code after resolving dependencies:

package main
import "fmt"
func main() { fmt.Println("hello") }

0.19.1

22 Mar 07:16
Compare
Choose a tag to compare

Support console.info() and console.debug() in the javascript browser sandbox (by @jonasb).

0.19.0

15 Mar 05:56
Compare
Choose a tag to compare

This release introduces three output-related features:

  • Auto-tail output.
  • Manual tail.
  • Empty placeholder.

⚠️ All three features are experimental and may be removed in future releases.

Auto-tail output

Suppose you have two code snippets where the second depends on the first:

a = 42
print("a =", a)
<codapi-snippet id="s-1" sandbox="python" editor="basic">
</codapi-snippet>
b = a * 2
print("b =", b)
<codapi-snippet sandbox="python" editor="basic" depends-on="s-1">
</codapi-snippet>

When you run the second snippet, it outputs the following:

a = 42
b = 84

It's probably not what you expect, because the code in the second snippet only prints b. But that's how snippet dependencies worked until now.

Now you can force the snippet to ignore the output of its dependencies and print only its own output. Use the output-tail attribute to do this:

<codapi-snippet sandbox="python" editor="basic" depends-on="s-1" output-tail>
</codapi-snippet>

Now it will only print b = 84.

Auto-tail only works for some languages (namely JS, Lua, PHP, Python, R, Ruby, TypeScript, Shell, and SQL). The language is inferred from the sandbox attribute by default, but you can set it manually with the syntax attribute.

For other languages, you'll need to use the manual tail (see below).

Manual tail

You can use output-tail to manually suppress some output and only show the tail. This works for both snippets with dependencies and regular snippets.

Suppose you use a third-party package to do some work and display the result:

import chatty

res = chatty.work()
print("res =", res)

For reasons beyond your control, chatty.work() prints a lot of stuff to stdout. You'd like to hide it from the reader and only show the result. To do this, add the output-tail attribute and print the horizontal rule separator (---) to mark the "tail":

import chatty

res = chatty.work()
print("---")
print("res =", res)
<codapi-snippet sandbox="python" editor="basic" output-tail>
</codapi-snippet>

This snippet ignores everything before and including --- and only shows res = ....

Empty output placeholder

Suppose you have a snippet that doesn't print anything:

res = work()
<codapi-snippet sandbox="python" editor="basic">
</codapi-snippet>

Previously, this snippet showed a blank output when run. It looked a bit confusing, and the reader might think that something was wrong.

Now, if the output is empty, the snippet will display a short reassuring ok message.

0.18.1

11 Mar 17:14
Compare
Choose a tag to compare

Change sandbox on the fly

You can now change the following sandbox attributes on the fly:

sandbox
engine
command
template
files

When you click the Run button, the newly set values are used.