An open API service indexing awesome lists of open source software.

https://github.com/richinfante/docgen

Rust + Spidermonkey + Servo -> Static Site Generator
https://github.com/richinfante/docgen

rust spidermonkey

Last synced: 2 months ago
JSON representation

Rust + Spidermonkey + Servo -> Static Site Generator

Awesome Lists containing this project

README

        

# docgen

**NOTE: Docgen is experimental "alpha" software.**

Docgen is a static site renderer which is built using servo's html5ever and spidermonkey. It aims to make static site generation to be effortless and removing templating languages such as liquid.

Docgen's template syntax is based on / inspired by the syntax used by vuejs's templates. the rationale behind this is that all templates become are normal HTML pages and do not need extra text nodes containing the conditional / template logic. (like liquid, mustache, others..). This means pages can be developed and tested in their pure template form, without needing much (or any) tooling to do so in a nice way.

Templates also allow tags to be run (At compile time) with the `static` attribute set.

Please note that the generation does **NOT** currently expose the normal javascript dom api, such as `document.createElement`, etc. It is an empty javascript context only used for templating. If this feature would be useful to you, file an issue with use cases / info.

## Feature Roadmap
these are features I'd like to have initially, in no particular order.
- [x] add html parser
- [x] add js engine
- [x] conditional logic with `x-if` (tentative name)
- [x] attribute variable expansion (`:href="link.title"` with `link = { title: 'HI' }` -> `href="HI"`)
- [x] layout includes via `layout` js variable and `x-content-slot` attribute.
- [x] iteration logic with `x-each` (tentative name) **Experimentally Implemented**
- [ ] **(partially implemented)** conditional css class generation (similar to vuejs's :class attribute). (can do bind `:class="compute_class_string_fn()"`)
- [x] html partials via `<slot src="file.html"></slot>`.
- [ ] **(partially implemented)** filesystem interaction - allow simple load to string from fs
- [ ] raw html
- [ ] way to extract the contents of a div to replace it. Potentially called `x-extract`
- [ ] json/yaml/etc data file loading for configuration / data.
- [ ] markdown support with front-matter data + rendering (similar to jekyll)
- [ ] page-fork rendering: instead of iterating a page via `x-each`, render multiple copies of a page with different elements. To be used for dynamic tagging. (this is a place where jekyll doesn't work well.)
- [ ] helper application to call the main `docgen` binary for site generation. This is the template engine, from which the actual site generator will discover supported template pages and render them for upload.

## Building from source
```bash
brew install yasm autoconf
set AUTOCONF="$(which autoconf)"
cargo build
```

## Runing example
```bash
cargo run -- -i examples/demo.html
```

## Process
1. render the page to html if it's markdown.
2. render using the main `docgen` process, in a top-down manner.
- evaluate any `script static` tags.
- replace all template variables

## Template Examples
At the moment, docgen only produces processes html templates. This will change in the future, with options for markdown, etc.

### Source Template
```html
<html>
<head>
<script static>
let links = [{
href: 'https://google.com',
title: 'google'
}, {
href: 'https://apple.com',
title: 'apple'
},{
href: 'https://amazon.com',
title: 'amazon'
}]



Hello, World