Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert legacy documentation #141

Open
brianmhunt opened this issue Jun 29, 2021 · 0 comments
Open

Convert legacy documentation #141

brianmhunt opened this issue Jun 29, 2021 · 0 comments

Comments

@brianmhunt
Copy link
Member

Background

Knockout has a lot of documentation, much of which is application to TKO as well. It's mostly written in Markdown. I've written a little documentation in Markdown as well.

In general, Markdown is an easily accessible format for documentation, but sufficiently dynamic that we should be able to reference everything from there.

Objective

  1. Add documentation to this monorepo
  2. Deploy the documentation with an automated command to e.g. Github Pages or Firebase (both being Fastly)
  3. Create a Github Action to auto-deploy on changes

Technical discussion

Some documentation is at:

The unified, remark processor looks to be an excellent preprocessor, with a good AST generator like this:

#!/usr/bin/env node
const fs = require('fs')
const unified = require('unified')
const markdown = require('remark-parse')
const html = require('remark-html');

const markdownText = fs.readFileSync('/dev/stdin', 'utf8')

unified()
  .use(markdown)
  .use(() => tree => console.log(JSON.stringify(tree, null, 2)))
  .use(html)
  .processSync(markdownText)
  .toString();

What might make sense is to skip the AST, or even JSX, and jump right to our own JSX object representation i.e.

interface JsxObject {
   element: string // tagName
   children?: JsxObject[],
   attributes?: Record<string, string>,
}

We'd need to create our own html-like processor that generates the JSX, but we could generate .json files that we could do something trivial to load the page like this:

observable(tko.jsx.createElement(await import('./docs/doc-as-markdown.json'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant