Public
Edited
Jan 10, 2023
Importers
Insert cell
Insert cell
Insert cell
function docPreview(html) {
const resPreview = document.createElement('div');
resPreview.style.border = '1px solid lightgray';
resPreview.style.borderRadius = '10px';
resPreview.style.padding = '10px 15px';
resPreview.innerHTML = html;
return resPreview;
}
Insert cell
function tag(title, description) {
let html = '';
html += `<span style="font-weight: bold; margin-right: 20px">${title}</span>`
html += `<span style="color: gray">${description ?? ''}</span>`
const res = docPreview(html);
res.value = {
type: 'tag',
title,
description,
};
return res;
}
Insert cell
viewof testTag = tag('Документирование', 'что-то интересное')
Insert cell
function doc(obj, title, signatures, spec) {
let html = '';
html += `<div style="font-weight: bold">${title}</div>`
return docPreview(html);
}
Insert cell
doc(doc, 'Функция документирования', '', ['', '', ''])
Insert cell
function basicType(title, checker) {
let html = '';
html += `<span style="font-weight: bold; margin-right: 20px">${title}</span>`
html += `<span style="color: gray">${String(checker)}</span>`
const res = docPreview(html);
res.value = {
type: 'tag',
title,
checker,
};
return res;
}
Insert cell
function taggedType(title, type) {
let html = '';
html += `<span style="font-weight: bold; margin-right: 20px">${title}</span>`
html += `<span style="color: gray">${type.value.title}</span>`
const res = docPreview(html);
res.value = {
type: 'tag',
title,
type,
};
return res;

}
Insert cell
function tupleType(...args) {
return {value: {
type: 'tuple',
args,
}}
}
Insert cell
function funResType(fun, ...args) {
return {value: {
type: 'funRes',
fun,
args,
}}
}
Insert cell
function constructorType(fun, ...args) {
return {value: {
type: 'tuple',
fun,
args,
}}
}
Insert cell
function funType(fun, ...args) {
return {value: {
type: 'fun',
fun,
args,
}}
}
Insert cell
number = basicType('number', v => typeof v === 'number')
Insert cell
boolean = basicType('boolean', v => typeof v === 'boolean')
Insert cell
context = basicType('context', v => true)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more