# aip.dev static site generator
This is the site generator for [aip.dev](https://aip.dev) and its forks. It
takes AIP files in a git repository and outputs a static website.
## Why?
We are not fans of rolling our own tools when off-the-shelf alternatives exist.
However, the AIP project has grown sufficiently mature to warrant it.
GitHub Pages normally automatically builds documentation with [Jekyll][], but
as the AIP system has grown, we are beginning to reach the limits of what
Jekyll can handle, and other off-the-shelf generators had similar issues:
- AIP adoption is handled through fork-and-merge and top-down configuration
files will lead to repetitive merge conflicts.
- Our grouping and listing logic has grown complicated, and had to be
maintained using complex and error-prone Liquid templates.
- Jekyll is extensible but GitHub requires specific Jekyll plugins, meaning we
can not use off-the-shelf solutions for planned features (e.g. tabbed code
examples).
- Lack of meaningful build CI caused failures.
- Working with the development environment was (really) slow.
There are some additional advantages that we unlock with a custom generator:
- We can override segments of AIPs using template extensions in new files
rather than modifying existing files.
- We can provide useful abstractions for common deviations between companies
(e.g. case systems) that minimize the need to fork AIPs.
- We can customize the Markdown parsing where necessary (tabs, hotlinking,
etc.).
## How does it work?
This is essentially split into three parts:
- Python code (`aip_site/`):
- The majority of the code is models (`aip_site/models/`) that represent the
fundamental concept of an AIP site. These are rolled up into a singleton
object called `Site` that is used everywhere. All models are
[dataclasses][] that get sent to templates.
- There is also a publisher class (`aip_site/publisher.py`) that is able to
slurp up a repo of AIPs and build a static site.
- There is some server code (`aip_site/server.py`) that can run a development
server.
- All remaining files are thin support code to avoid repeating things in or
between the above.
- Templates (`support/templates/`) are [Jinja2][] templates containing (mostly)
HTML that makes up the layout of the site.
- Assets (`support/assets/` and `support/scss/`) are other static files. SCSS
is automatically compiled into CSS at publication.
Of the models, there are three models in particular that matter:
- **Site:** A singleton that provides access to all scopes, AIPs, and static
pages. This is sent to every template as the `site` variable.
- **AIP:** A representation of a single AIP, including both content and
metadata. This is sent to the AIP rendering template as the `aip` variable.
- **Scope:** A group of AIPs that apply to a particular scope. The "general"
scope is special, and is the "root" group. This is sent to the AIP _listing_
template as the `scope` variable.
Templates are [jinja2][] files in the `templates/` directory.
**Note:** We run Jinja in with "strict undefined", so referencing an undefined
variable in a template is a hard error rather than an empty string.
### Entry points
There are two entry points for the app. The _publisher_
(`aip_site/publisher.py`) is the program that iterates over the relevant
directories, renders HTML files, and writes them out to disk. The _app_
(`aip_site/server.py`) is a lightweight Flask app that provides a development
server.
These entry points are routed through the CLI file (`aip_site/cli.py`); when
this application is installed using pip, it makes the `aip-site-gen`
(publisher) and `aip-site-serve` (server) commands available.
### Extensions
This site generator includes a basic extension system for AIPs. When processing
AIPs as plain Markdown files, it will make any Markdown (level 2 or 3) header
into a block. Therefore...
```md
## Foo bar baz
Lorem ipsum dolor set amet
```
Becomes...
```j2
{% block foo_bar_baz %}
## Foo bar baz
Lorem ipsum dolor set amet
{% endblock %}
```
That allows an overriding template to extend the original one and override
sections:
```j2
{% extends aip.templates.generic %}
{% block foo_bar_baz %}
## My mo-betta foo bar baz
Lorem ipsum dolor set something-not-amet
{% endblock %}
```
[dataclasses]: https://docs.python.org/3/library/dataclasses.html
[jekyll]: https://jekyllrb.com/
[jinja2]: https://jinja.palletsprojects.com/en/2.11.x/
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共82个文件
scss:21个
py:18个
j2:17个
资源分类:Python库 所属语言:Python 资源全名:aip-site-generator-0.6.0.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
aip-site-generator-0.6.0.tar.gz (82个子文件)
aip-site-generator-0.6.0
MANIFEST.in 138B
PKG-INFO 5KB
aip_site_generator.egg-info
PKG-INFO 5KB
requires.txt 190B
not-zip-safe 1B
SOURCES.txt 3KB
entry_points.txt 106B
top_level.txt 9B
dependency_links.txt 1B
LICENSE 11KB
setup.cfg 38B
VERSION 6B
aip_site
server.py 3KB
models
scope.py 4KB
site.py 5KB
__init__.py 0B
aip.py 6KB
page.py 4KB
md.py 5KB
utils.py 1KB
cli.py 1KB
jinja
__init__.py 0B
ext
sample.py 5KB
__init__.py 0B
tab.py 2KB
loaders.py 3KB
env.py 1KB
support
templates
search.html.j2 1KB
aip.html.j2 2KB
layouts
base.html.j2 3KB
redirect.html.j2 544B
aip-listing.html.j2 2KB
page.html.j2 1KB
index.html.j2 2KB
includes
state_banners
reviewing.html.j2 316B
draft.html.j2 189B
rejected.html.j2 125B
replaced.html.j2 212B
withdrawn.html.j2 126B
breadcrumb.html.j2 1KB
footer.html.j2 415B
nav.html.j2 986B
header.html.j2 5KB
search.js.j2 443B
assets
misc
ebnf-filtering.txt 5KB
images
glue-icons.svg 14KB
github.png 4KB
js
global.js 3KB
aip
aip-graphviz.js 1KB
aip-index.js 992B
search
tipuesearch.min.js 10KB
pagination.js 982B
tipuesearch_set.js 3KB
graphviz
viz.js 11KB
lite.render.js 1.37MB
syntax.js 4KB
favicon.ico 5KB
scss
style.scss 466B
hero.scss 851B
print.scss 1KB
imports
sidebar.scss 1KB
aip
news.scss 611B
header.scss 67B
badges.scss 443B
nav.scss 184B
tables.scss 1KB
breadcrumbs.scss 218B
footer.scss 240B
lists.scss 128B
tabs.scss 889B
header.scss 1KB
headings.scss 600B
syntax.scss 3KB
nav.scss 3KB
tables.scss 102B
colors.scss 4KB
callouts.scss 942B
search.scss 1KB
__init__.py 0B
publisher.py 5KB
setup.py 2KB
README.md 4KB
共 82 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功