Use cog prolog

Refs https://github.com/simonw/llm/issues/151#issuecomment-1675730608
This commit is contained in:
Simon Willison 2023-08-11 23:17:50 -07:00
parent 50d3b8b25b
commit 7303bc3e34
5 changed files with 4 additions and 12 deletions

View file

@ -27,8 +27,9 @@ jobs:
pytest
- name: Check if cog needs to be run
run: |
cog docs/usage.md
cog --check docs/*.md
cog --check \
-p "import sys, os; sys._called_from_test=True; os.environ['LLM_USER_PATH'] = '/tmp'" \
docs/*.md
- name: Run Black
run: |
black --check .

View file

@ -23,7 +23,7 @@
# Rebuild docs with cog
@cog:
pipenv run cog -r docs/*.md
pipenv run cog -r -p "import sys, os; sys._called_from_test=True; os.environ['LLM_USER_PATH'] = '/tmp'" docs/*.md
# Serve live docs on localhost:8000
@docs: cog

View file

@ -12,9 +12,6 @@ Example output:
<!-- [[[cog
from click.testing import CliRunner
import sys, os
os.environ["LLM_USER_PATH"] = "/tmp"
sys._called_from_test = True
from llm.cli import cli
result = CliRunner().invoke(cli, ["aliases", "list"])
cog.out("```\n{}```".format(result.output))

View file

@ -4,8 +4,6 @@ This page lists the `--help` output for all of the `llm` commands.
<!-- [[[cog
from click.testing import CliRunner
import sys
sys._called_from_test = True
from llm.cli import cli
def all_help(cli):
"Return all help for Click command and its subcommands"

View file

@ -90,12 +90,8 @@ llm models list --options
Output:
<!-- [[[cog
from click.testing import CliRunner
import os, sys
sys._called_from_test = True
from llm.cli import cli
os.environ["LLM_USER_PATH"] = "/tmp"
result = CliRunner().invoke(cli, ["models", "list", "--options"])
del os.environ["LLM_USER_PATH"]
cog.out("```\n{}\n```".format(result.output))
]]] -->
```