46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
|
import pathlib
|
||
|
from ssg.tags import *
|
||
|
from ssg.utils import *
|
||
|
from markup import iwmlibdoc_document, sitemap_main
|
||
|
|
||
|
src = pathlib.Path('..')
|
||
|
content = src / 'lib'
|
||
|
|
||
|
async def main(path:pathlib.Path):
|
||
|
"""Typical main program, setting up content publishers, defining the site structure and
|
||
|
typical order of generating initial pages and observing subsequent changes.
|
||
|
"""
|
||
|
|
||
|
# 2. Build the site structure with nested context managers
|
||
|
with site('iwmlibdoc', path=path, doc=iwmlibdoc_document) as docsite:
|
||
|
# If we use symlinks the css and image files can be modified without
|
||
|
# notifications.
|
||
|
docsite.symlink(src, 'css')
|
||
|
docsite.symlink(src, 'assets')
|
||
|
docsite.symlink(src, 'dist')
|
||
|
# structures can be created in a loop to ensure indentical hierarchies
|
||
|
|
||
|
sitemap = page('sitemap.html',
|
||
|
title='Sitemap',
|
||
|
main=sitemap_main)
|
||
|
static_folder(content)
|
||
|
|
||
|
# 3. Start generation.
|
||
|
docsite.generate()
|
||
|
|
||
|
#print(docsite)
|
||
|
# 4. Let's check whether all links are working...
|
||
|
# site.validate()
|
||
|
|
||
|
await docsite.observe_filesystem(timeout=120)
|
||
|
|
||
|
def run():
|
||
|
default = pathlib.Path('.') / 'dist'
|
||
|
if default.exists():
|
||
|
shutil.rmtree(default)
|
||
|
default.mkdir(parents=True)
|
||
|
asyncio.run(main(default))
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
run()
|