From 6652365fee90917f42883298f333471965f54776 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Wed, 3 Jun 2020 17:03:42 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9A=20Docs=20for=20module=20members?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project.toml | 2 +- assets/editor.js | 19 +++++++++++++------ src/runner/PlutoRunner.jl | 8 ++++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index 4a3421b134..75cf611f95 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ name = "Pluto" uuid = "c3e4b0f8-55cb-11ea-2926-15256bba5781" license = "MIT" authors = ["Fons van der Plas ", "Mikołaj Bochenski "] -version = "0.9.2" +version = "0.9.3" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/assets/editor.js b/assets/editor.js index 28bf9a780c..91fc9ecb2e 100644 --- a/assets/editor.js +++ b/assets/editor.js @@ -145,12 +145,19 @@ function createCodeMirrorInsideCell(cellNode, code) { }) cm.on("cursorActivity", (cm) => { - const token = cm.getTokenAt(cm.getCursor()) - - if (token.type != null && token.type != "string") { - updateDocQuery(token.string) + if (cm.somethingSelected()) { + let sel = cm.getSelection() + if (!/[\s]/.test(sel)){ + // no whitespace + updateDocQuery(sel) + } + } else { + let token = cm.getTokenAt(cm.getCursor()) + if (token.type != null && token.type != "string") { + updateDocQuery(token.string) + } } - }); + }) cm.on("blur", (cm, e) => { if (document.hasFocus()) { @@ -234,7 +241,6 @@ function renderOutput(msg, ctx) { } } else { const result = Function(script.innerHTML).bind(newContainer)() - console.log(result) if (result && result.nodeType === Node.ELEMENT_NODE) { script.parentElement.insertBefore(result, script) } @@ -299,6 +305,7 @@ function updateLocalCellOutput(cellNode, msg) { ) cellNode.classList.toggle("inline-output", !msg.errored && + !!msg.output && (msg.mime == "application/vnd.pluto.tree+xml" || msg.mime == "text/plain") ) cellNode.classList.toggle("error", diff --git a/src/runner/PlutoRunner.jl b/src/runner/PlutoRunner.jl index f3da895a3a..560fff78c2 100644 --- a/src/runner/PlutoRunner.jl +++ b/src/runner/PlutoRunner.jl @@ -456,8 +456,12 @@ end function doc_fetcher(query, workspace::Module=current_module) try - obj = getfield(workspace, Symbol(query)) - (repr(MIME"text/html"(), Docs.doc(obj)), :👍) + obj = Core.eval(workspace, Meta.parse(query)) + if obj isa Expr + (nothing, :👎) + else + (repr(MIME"text/html"(), Docs.doc(obj)), :👍) + end catch ex (nothing, :👎) end