{"id":21323820,"url":"https://github.com/richinfante/docgen","last_synced_at":"2025-03-15T23:19:06.768Z","repository":{"id":38333171,"uuid":"180682463","full_name":"richinfante/docgen","owner":"richinfante","description":"Rust + Spidermonkey + Servo -\u003e Static Site Generator","archived":false,"fork":false,"pushed_at":"2023-06-13T20:27:09.000Z","size":155,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T12:12:40.174Z","etag":null,"topics":["rust","spidermonkey"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/richinfante.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-11T00:09:27.000Z","updated_at":"2023-09-08T17:52:35.000Z","dependencies_parsed_at":"2024-11-21T20:38:31.065Z","dependency_job_id":null,"html_url":"https://github.com/richinfante/docgen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richinfante%2Fdocgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richinfante%2Fdocgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richinfante%2Fdocgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richinfante%2Fdocgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/richinfante","download_url":"https://codeload.github.com/richinfante/docgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243801991,"owners_count":20350167,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rust","spidermonkey"],"created_at":"2024-11-21T20:27:26.835Z","updated_at":"2025-03-15T23:19:06.749Z","avatar_url":"https://github.com/richinfante.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docgen\n\n**NOTE: Docgen is experimental \"alpha\" software.**\n\nDocgen 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.\n\nDocgen'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.\n\nTemplates also allow \u003cscript\u003e tags to be run (At compile time) with the `static` attribute set.\n\nPlease 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.\n\n## Feature Roadmap\nthese are features I'd like to have initially, in no particular order.\n- [x] add html parser\n- [x] add js engine\n- [x] conditional logic with `x-if` (tentative name)\n- [x] attribute variable expansion (`:href=\"link.title\"` with `link = { title: 'HI' }` -\u003e `href=\"HI\"`)\n- [x] layout includes via `layout` js variable and `x-content-slot` attribute.\n- [x] iteration logic with `x-each` (tentative name) **Experimentally Implemented**\n- [ ] **(partially implemented)** conditional css class generation (similar to vuejs's :class attribute). (can do bind `:class=\"compute_class_string_fn()\"`)\n- [x] html partials via `\u003cslot src=\"file.html\"\u003e\u003c/slot\u003e`.\n- [ ] **(partially implemented)** filesystem interaction - allow simple load to string from fs\n- [ ] raw html\n- [ ] way to extract the contents of a div to replace it. Potentially called `x-extract`\n- [ ] json/yaml/etc data file loading for configuration / data.\n- [ ] markdown support with front-matter data + rendering (similar to jekyll)\n- [ ] 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.)\n- [ ] 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.\n\n## Building from source\n```bash\nbrew install yasm autoconf\nset AUTOCONF=\"$(which autoconf)\"\ncargo build\n```\n\n## Runing example\n```bash\ncargo run -- -i examples/demo.html\n```\n\n## Process\n1. render the page to html if it's markdown.\n2. render using the main `docgen` process, in a top-down manner.\n  - evaluate any `script static` tags.\n  - replace all template variables\n\n## Template Examples\nAt the moment, docgen only produces processes html templates. This will change in the future, with options for markdown, etc.\n\n### Source Template\n```html\n\u003chtml\u003e\n\u003chead\u003e\n  \u003cscript static\u003e\n  let links = [{\n    href: 'https://google.com',\n    title: 'google'\n  }, {\n    href: 'https://apple.com',\n    title: 'apple'\n  },{\n    href: 'https://amazon.com',\n    title: 'amazon'\n  }]\n  \u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cul\u003e\n    \u003cli x-for=\"link in links\"\u003e\n      \u003ca :href=\"link.href\"\u003e{{link.title}}\u003c/a\u003e\n    \u003c/li\u003e\n  \u003c/ul\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Result Output\n```html\n\u003chtml\u003e\n\u003chead\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cul\u003e\n    \u003cli\u003e\n      \u003ca href=\"https://google.com\"\u003egoogle\u003c/a\u003e\n    \u003c/li\u003e\u003cli\u003e\n      \u003ca href=\"https://apple.com\"\u003eapple\u003c/a\u003e\n    \u003c/li\u003e\u003cli\u003e\n      \u003ca href=\"https://amazon.com\"\u003eamazon\u003c/a\u003e\n    \u003c/li\u003e\n  \u003c/ul\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Converting from liquid\n### If statements\n```html\n{% if variable_name %}\n\u003cspan\u003eHello, World!\u003c/span\u003e\n{% endif %}\n```\n\n```html\n\u003cspan x-if=\"variable_name\"\u003eHello, World\u003c/span\u003e\n```\n\n### Attribute bindings\n```html\n\u003cspan class=\"{{className}}\"\u003eTest\u003c/span\u003e\n```\n\nNote: the `:class` binding *may* be updated in the future to allow a dictionary, which in turn renders to a space-separated class string based on all the keys that have truthy values. (equivalent to: `Object.entries(classDict).filter(el =\u003e el[1]).map(el =\u003e el[0]).join(' ')`)\n\n```html\n\u003cspan :class=\"className\"\u003eTest\u003c/span\u003e\n```\n\n\n### For loops\nnote: for loops are not feature complete. All for loops currently bind to `item` and the syntax is likely to change.\n```html\n\u003cul\u003e\n{% for item in items %}\n  \u003cli\u003e\n    \u003ca href=\"{{item.url}}\"\u003e{{item.title}}\u003c/a\u003e\n  \u003c/li\u003e\n{% endfor %}\n\u003c/ul\u003e\n```\n\n```html\n\u003cul\u003e\n  \u003cli x-for=\"item in items\"\u003e\n    \u003ca :href=\"item.url\"\u003e{{item.title}}\u003c/a\u003e\n  \u003c/li\u003e\n\u003c/ul\u003e\n\n\u003c!-- or: --\u003e\n\u003cul\u003e\n  \u003cli x-each=\"items\" x-as=\"item\"\u003e\n    \u003ca :href=\"item.url\"\u003e{{item.title}}\u003c/a\u003e\n  \u003c/li\u003e\n\u003c/ul\u003e\n```\n\n### Template Extension\n**hello.md**\n```md\n\u003cscript\u003e\nlayout = './base.html'\ntitle = 'Example'\n\u003c/script\u003e\n\n# Hello, World\n```\n\n**base.html**\n```html\n\u003chtml\u003e\n  \u003chead\u003e{{child.title}}\u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv x-content-slot\u003e\u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n**out.html**\n```html\n\u003chtml\u003e\n  \u003chead\u003eExample\u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eHello, World\u003c/h1\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### HTML Include\nThis currently only works with HTML files.\nIn a later revision, they will work with all supported types.\n\n```html\n\u003cslot src=\"./example.html\"\u003e\u003c/slot\u003e\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichinfante%2Fdocgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frichinfante%2Fdocgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichinfante%2Fdocgen/lists"}