Skip to content

Commit

Permalink
Start laying ground work for opengraph image generation
Browse files Browse the repository at this point in the history
  • Loading branch information
leouieda committed Apr 29, 2024
1 parent b327512 commit 9d68048
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ jobs:
- name: Install the package and requirements
run: python -m pip install `ls dist/*.whl`[jupyter]

- name: Install the documentation requirements
run: python -m pip install env/requirements-docs.txt

- name: List installed packages
run: python -m pip freeze

Expand Down
26 changes: 22 additions & 4 deletions doc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@
# Distributed under the terms of the MIT License.
# SPDX-License-Identifier: MIT
"""Trying out the API to build the site with a script instead of the CLI."""
import functools
import sys

from PIL import Image, ImageDraw, ImageFont
import nene

if __name__ == "__main__":

def build(config_file, verbose=True):
"""
Build the website from the sources
"""
# Create a Rich Console for printing status updates. To omit the messages,
# don't pass the console and style to the functions below.
console, style = nene.printing.make_console(verbose=True)
console, style = nene.printing.make_console(verbose=verbose)
# So we know that we're using this script and not the "nene" app.
console.rule()
console.print(":snake: Building from the 'build.py' Python script.", style=style)
console.rule()

# Generate the website structure based on the YAML configuration file.
site, source_files, config, build = nene.build(
"config.yml", console=console, style=style
config_file, console=console, style=style
)
# Render the HTML for the website.
nene.render(site, config, build, console=console, style=style)
Expand All @@ -26,7 +32,19 @@
nene.export(
site, source_files["copy"], config["output_dir"], console=console, style=style
)
return config, source_files


if __name__ == "__main__":
config, source_files = build("config.yml", verbose=True)
console, style = nene.printing.make_console(verbose=True)
# If the script is called with the "-s" command line option, serve the
# website and open it in a browser.
if "-s" in sys.argv:
nene.serve(config, source_files, console=console, style=style)
nene.serve(
config,
source_files,
console=console,
style=style,
rebuild=functools.partial(build, verbose=False),
)
197 changes: 197 additions & 0 deletions doc/images/thumbnail/og_background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions env/requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pillow==10.3.*
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- make
- pip:
- -r env/requirements-build.txt
- -r env/requirements-docs.txt
- -r env/requirements-style.txt
- -r env/requirements-test.txt
- -e .[jupyter]
Loading

0 comments on commit 9d68048

Please sign in to comment.