Doctoring the Docs

About Me

I told my doctor that I broke my arm in two places.

They told me to stop going to those places.

Some History

The Old Docs (index)

The Old Docs (api)

The Current Docs (index)

The Current Docs (api)

Did you hear about the Obstetrician who became a stand-up comedian?

It’s all about the delivery for some people.

My First Hack

The Boilerplate

Astro CLI documentation starter

Regex

Examples (txt)

Examples (annotated)

Example 1 (sections)

const SECTION_SPLITTER = "---SECTION_SPLITTER---";

// convert split sections to explicit string from regex
let scrubbedContent = textContent.replace(
  new RegExp("^[=,-]+$", "gm"),
  SECTION_SPLITTER
);

const rawSections = scrubbedContent
  .split(SECTION_SPLITTER)
  .map((section) => scrubContent(section.trim()));

Example 2 (section titles)

const TITLE_SPLITTER = "---TITLE_SPLITTER---";
const sections: HelpSection[] = rawSections.map((section, index) => {
  const lines: string[] = section.split("\n");

  const [firstLine, ...otherLines] = lines;

  const scrubbedFirstLine = firstLine.replace(
    new RegExp("\\s{2,}", "gm"),
    TITLE_SPLITTER
  );

  const [title, rawAnchor] = scrubbedFirstLine.split(TITLE_SPLITTER);

Example 4 (templating)

The Result (light)

The Result (dark)

What’s the difference between a general practitioner and a specialist?

One treats what you have, the other thinks you have what they treat.

The Second Hack

Neovim source: gen_help_html (outline)

Neovim source: gen_help_html (visit_node)

Neovim source: gen_help_html (visit_node:codeblock)

Neovim source: gen_help_html (gen_css)

Neovim source: gen_help_html (logo, etc)

Neovim source: gen_help_html (toc)

Forking neovim (why)

  • Reduced repetition in output
  • Easier custom theming and light/dark mode

Forking neovim (example)

Before:

elseif node_name == 'argument' then
  return ('%s<code>{%s}</code>'):format(ws(), text)

After:

elseif node_name == 'argument' then
  return ('%s`{%s}`'):format(ws(), text)

I’m looking for a good medical TV Show…

… but I don’t want no Scrubs.

The Current State

Rethinking the approach

  • No Forking
  • Use the existing html output
  • Strip repetitive sections

Why still markdown

Frontmatter

Getting the content

The Result

https://cmgriffing.github.io/neovim-docs-web/en/

Thanks to Algolia

Docsearch is free for open source projects

Why did Dracula go to the doctor?

He couldn’t stop coffin!

Thanks