luma doc: The Manual Lives Inside the Compiler
Here’s a question every programmer knows: does the version I have installed actually do what the website says?
Documentation usually lives somewhere else: a website, a wiki, a PDF. It describes the newest version, or an old one, or something in between. You read about a feature, try it, and find out your compiler doesn’t have it yet. Or it changed. Or the page is for a different release.
Luma 0.2.0 solves this in a simple way: the manual is built into the compiler.
luma docThat’s it. No website, no internet, no files to download. The documentation comes inside the luma program itself, and it always describes exactly the version you have. If your compiler has a feature, you can read about it. If you can read about it, your compiler has it.
Other languages have tools that look up the documentation of a function or a package. Luma goes further: the whole manual, from the first steps to every feature, is part of the compiler. We think that fits Luma perfectly.
Start with the contents
luma doc on its own shows the table of contents: every page with a one-line hint of what it’s about.
The Luma manual
luma doc <topic> a page, or the part a topic is about
luma doc <topic> <section> one section of a page: luma doc objects init
luma doc -s <word> every line that mentions a word
Start here
getting-started build the compiler and run your first program
cli every command and option
editors errors as you type in VS Code, Neovim, Helix and others
The language
basics how a program is laid out, names, keywords
comments // comments and how to use them
types int, float, byte, bool, str
optional email: ?str = nil, if email != nil { ... }, nick ?? "anonymous"
...The hints are written as tiny examples, so often the contents alone remind you of the syntax you were looking for.
Ask about anything
Name a page, and you get it:
luma doc objectsBut you don’t need to know the page names. Ask about a keyword, a built-in function or a method, and Luma takes you to the right place:
luma doc convert # the page on converting between types
luma doc lock # straight to the section about lock
luma doc obj # the page on objectsLocked values: lock
-------------------
lock before a declaration makes a value that is fixed when the program is
compiled and can never change:
lock PI: float = 3.14159
lock MAX_ITEMS: int = 100Just the part you need
Long pages are split into sections. Add a few words of a section’s title, and you get only that section:
luma doc objects initinit: a constructor
-------------------
When making an object takes more than setting fields, give the obj an init
method. Then objects are made by calling the obj's name like a function, and
init runs on the new object:
...Search the whole manual
Don’t know where something is? Search every line:
luma doc -s circlecli › luma doc [topic [section] | -s word]
luma doc -s circle # every line of the manual that mentions a word
memory › Shared values stay as long as they are used
…s and sets can't form a circle (a list can't contain itself), so they ar…Each result tells you the page and the section, so you know exactly where to look next.
Typos are forgiven
We all mistype. Luma notices:
$ luma doc objetcs
No topic "objetcs".
Did you mean: object, objectsAnd a word that isn’t a topic is looked up anyway: luma doc recursion lists every section that talks about recursion.
Made for the terminal
In a terminal, the manual has colors, and a long page opens in a pager (less, or whatever $PAGER says), so you can scroll and search. Pipe it to a file or another program, and it’s plain text. Set NO_COLOR if you prefer it without colors.
It’s fast, too: there’s nothing to load and nothing to fetch. The answer is on screen before you could open a browser tab.
The manual can’t lie
This is the part we’re proudest of.
Every page of the manual is full of examples, and most of them show the output they produce. Our tests take every single example from the manual, run it both interpreted and compiled, and check that the output is exactly what the manual says. If we change Luma and an example stops working, or prints something different, the tests fail and the change can’t go in.
So when the manual says:
text: str = "42"
n: int = convert(text)
print(n + 1)Output:
43you can be sure it really prints 43, in both modes, in the version you have.
The tests also check the manual itself: every topic leads to exactly one place, and every page shows cleanly in the terminal.
Why this matters
- For learners: the answer is one command away, in the same window where you write code. No searching the web, no outdated tutorials.
- Offline: on a train, on a server with no internet, in a classroom with a bad connection, the manual is there.
- For teams: everyone reads the documentation for the version they actually run. An old compiler shows the old manual, a new one the new manual.
- For us: writing the documentation is part of building a feature. A feature isn’t finished until it’s in the manual, with examples that pass.
The same text, everywhere
The pages behind luma doc are ordinary Markdown files. The same text appears in the terminal and in your editor when you hover over a built-in name. One source, always in step.
Try it
luma docThen pick anything that looks interesting. With Luma, learning the language and using it happen in the same place.