Make resource dirs modules
This commit is contained in:
parent
1c130a7f73
commit
7e2f60c243
3 changed files with 14 additions and 3 deletions
0
doc/src/hexdoc/_export/resources/__init__.py
Normal file
0
doc/src/hexdoc/_export/resources/__init__.py
Normal file
|
@ -24,10 +24,9 @@ class HexcastingPlugin(LoadResourceDirsImpl, LoadTaggedUnionsImpl, ModVersionImp
|
|||
# lazy import because generated may not exist when this file is loaded
|
||||
# eg. when generating the contents of generated
|
||||
# so we only want to import it if we actually need it
|
||||
import hexdoc._export.generated
|
||||
import hexdoc._export.resources
|
||||
from hexdoc._export import generated, resources
|
||||
|
||||
return [hexdoc._export.generated, hexdoc._export.resources]
|
||||
return [generated, resources]
|
||||
|
||||
@staticmethod
|
||||
@hookimpl
|
||||
|
|
|
@ -5,6 +5,7 @@ import subprocess
|
|||
from collections.abc import Iterator
|
||||
from contextlib import ExitStack, contextmanager
|
||||
from pathlib import Path
|
||||
from textwrap import dedent
|
||||
from typing import Callable, Literal, Self, TypeVar, overload
|
||||
|
||||
from pydantic.dataclasses import dataclass
|
||||
|
@ -52,6 +53,17 @@ class ModResourceLoader:
|
|||
# clear the export dir so we start with a clean slate
|
||||
if props.export_dir and export:
|
||||
subprocess.run(["git", "clean", "-fdX", props.export_dir])
|
||||
|
||||
write_to_path(
|
||||
props.export_dir / "__init__.py",
|
||||
dedent(
|
||||
"""\
|
||||
# This directory is auto-generated by hexdoc.
|
||||
# Do not edit or commit these files.
|
||||
"""
|
||||
),
|
||||
)
|
||||
|
||||
return cls.load_all(props, pm, export=export)
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in a new issue