Add check that there are samples for each language

pull/2779/head
Alex Dima 3 years ago
parent f012a2aeee
commit 37f12e39a3
No known key found for this signature in database
GPG Key ID: 39563C1504FDD0C9

@ -13,10 +13,9 @@
*/
/** @typedef {import('../build/utils').IFile} IFile */
const glob = require('glob');
const path = require('path');
const fs = require('fs');
const { REPO_ROOT, removeDir, ensureDir, readFiles, writeFiles } = require('../build/utils');
const { REPO_ROOT, removeDir, readFiles, writeFiles } = require('../build/utils');
const ts = require('typescript');
/**@type { IMetadata } */
const metadata = require('../metadata.js');

@ -7,6 +7,7 @@
/** @typedef {import('../build/utils').IFile} IFile */
const glob = require('glob');
const path = require('path');
const fs = require('fs');
const cp = require('child_process');
@ -26,9 +27,51 @@ const MONACO_EDITOR_VERSION = (() => {
})();
removeDir(`../monaco-editor-website`);
checkSamples();
generateWebsite();
/**
* Check that there are samples for all available languages
*/
function checkSamples() {
let languages = glob
.sync('src/basic-languages/*/*.contribution.ts', { cwd: REPO_ROOT })
.map((f) => path.dirname(f))
.map((f) => f.substring('src/basic-languages/'.length));
languages.push('css');
languages.push('html');
languages.push('json');
languages.push('typescript');
// some languages have a different id than their folder
languages = languages.map((l) => {
switch (l) {
case 'coffee':
return 'coffeescript';
case 'protobuf':
return 'proto';
case 'solidity':
return 'sol';
case 'sophia':
return 'aes';
default:
return l;
}
});
let fail = false;
for (const language of languages) {
const expectedSamplePath = path.join(REPO_ROOT, `website/index/samples/sample.${language}.txt`);
if (!fs.existsSync(expectedSamplePath)) {
console.error(`Missing sample for ${language} at ${expectedSamplePath}`);
fail = true;
}
}
if (fail) {
process.exit(1);
}
}
/**
* @param {string} dataPath
* @param {string} contents

@ -0,0 +1,7 @@
F0 := IMDB.File_actors;
CountActors := RECORD
F0.ActorName;
UNSIGNED C := COUNT(GROUP);
END;
MoviesIn := TABLE(F0,CountActors,ActorName);
OUTPUT(TOPN(MoviesIn,100,-C));

@ -0,0 +1,14 @@
import material/material;
export {
demoMakeHelloWorld(onClose : () -> void) -> Material;
}
demoMakeHelloWorld(onClose : () -> void) -> Material {
MCenter(
MLines2(
MText("Hello, world!", []),
MTextButton("CLOSE", onClose, [], [])
)
);
}

@ -0,0 +1,17 @@
LEX Paid Escrow.
LEXON: 0.2.12
COMMENT: 3.f - an escrow that is controlled by a third party for a fee.
“Payer” is a person.
“Payee” is a person.
“Arbiter” is a person.
“Fee” is an amount.
The Payer pays an Amount into escrow,
appoints the Payee,
appoints the Arbiter,
and also fixes the Fee.
CLAUSE: Pay Out.
The Arbiter may pay from escrow the Fee to themselves,
and afterwards pay the remainder of the escrow to the Payee.
CLAUSE: Pay Back.
The Arbiter may pay from escrow the Fee to themselves,
and afterwards return the remainder of the escrow to the Payer.

@ -0,0 +1,16 @@
class Random < Liquid::Block
def initialize(tag_name, markup, tokens)
super
@rand = markup.to_i
end
def render(context)
value = rand(@rand)
super.sub('^^^', value.to_s) # calling `super` returns the content of the block
end
end
Liquid::Template.register_tag('random', Random)
text = " {% random 5 %} you have drawn number ^^^, lucky you! {% endrandom %} "
@template = Liquid::Template.parse(text)
@template.render # will return "you have drawn number 1, lucky you!" in 20% of cases

@ -0,0 +1,5 @@
MODULE HelloWorld EXPORTS Main;
FROM IO IMPORT Put;
BEGIN
Put("Hello World\n")
END HelloWorld.

@ -0,0 +1,4 @@
.ob out1 out2 out3
--1-- - wait 110000
.ilb in1 in0 wait ack nack
.symbolic state<3> state<2>;aaa bbb; # comment

@ -0,0 +1,11 @@
syntax = "proto3";
import public "other.proto";
/* SearchRequest represents a search query, with pagination options to
* indicate which results to include in the response. */
message SearchRequest {
required string query = 1;
optional int32 page_number = 2; // Which page number do we want?
optional int32 result_per_page = 3; // Number of results to return per page.
}

@ -0,0 +1,45 @@
// Run this cell using Ctrl+Enter (⌘+Enter on Mac)
// Then run the next cell to see the output
open Microsoft.Quantum.Diagnostics;
operation QubitsDemo () : Unit {
// This line allocates a qubit in state |0⟩
use q = Qubit();
Message("State |0⟩:");
// This line prints out the state of the quantum computer
// Since only one qubit is allocated, only its state is printed
DumpMachine();
// This line changes the qubit from state |0⟩ to state |1⟩
X(q);
Message("State |1⟩:");
DumpMachine();
// This line changes the qubit to state |-⟩ = (1/sqrt(2))(|0⟩ - |1⟩)
// That is, this puts the qubit into a superposition
// 1/sqrt(2) is approximately 0.707107
H(q);
Message("State |-⟩:");
DumpMachine();
// This line changes the qubit to state |-i⟩ = (1/sqrt(2))(|0⟩ - i|1⟩)
S(q);
Message("State |-i⟩:");
DumpMachine();
// This will put the qubit into an uneven superposition,
// where the amplitudes of |0⟩ and |1⟩ have different moduli
Rx(2.0, q);
Ry(1.0, q);
Message("Uneven superposition state:");
DumpMachine();
// This line returns the qubit to state |0⟩
Reset(q);
}

@ -0,0 +1,7 @@
SELECT ?x ?name
{
?x foaf:mbox <mailto:alice@example> .
?x foaf:knows ?a1 .
?a1 foaf:knows ?a2 .
?a2 foaf:name ?name .
}
Loading…
Cancel
Save