The @sypnia/learn package
Read and validate lesson files, render a lesson for a level, run checks, and read progress from your code.
On this page
npm install @sypnia/learn| Import | For |
|---|---|
@sypnia/learn/format | reading, validating and rendering lesson files: for authors and their tools |
@sypnia/learn/checks | running a lesson’s checks on your machine while you write it |
@sypnia/learn/client | the Learn API: courses, lessons, exercises, progress, explanations |
Authors
import { lint, parseLesson, render } from '@sypnia/learn/format';
const { problems } = await lint('./learn/use-cases-first');
if (problems.length) console.table(problems);
const lesson = await parseLesson('./learn/use-cases-first/failures-have-names.lesson.md');
const { text } = render(lesson, { level: 'starter', language: 'en', slots: { case: { title: 'Order for today', failures: [{ name: 'OutOfStock' }] } } });Apps and scripts
import { createLearn } from '@sypnia/learn/client';
const learn = createLearn(); // the session of `npx @sypnia/app login`
const next = await learn.next();
const exercise = await learn.exercises.start(next.id, { project: 'la-espiga' });
const result = await learn.exercises.check(exercise.id);
console.log(result.status, result.checks);createLearn({ token, baseUrl }) takes a personal access token and your engine’s address instead. A token belongs to a person: Learn has no secret key for apps, because every record belongs to someone.