Skip to content

Commit f23a324

Browse files
committed
feat: Builder source_dir parameter for non-package loads
1 parent 417e479 commit f23a324

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

examples/weird-install/_quarto.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# quarto stuff ----------------------------------------------------------------
2+
project:
3+
type: website
4+
5+
website:
6+
title: weird-install example
7+
navbar:
8+
left:
9+
- file: reference/index.qmd
10+
text: "Reference"
11+
12+
13+
# quartodoc -------------------------------------------------------------------
14+
15+
quartodoc:
16+
package: null
17+
source_dir: ./src
18+
sections:
19+
- title: Some functions
20+
desc: These functions inspect and parse docstrings.
21+
contents:
22+
- some_module.some_function
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def some_function():
2+
"""A function defined in a random python script"""

quartodoc/autosummary.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ class Builder:
336336
The output path for a sidebar yaml config (by default no config generated).
337337
rewrite_all_pages:
338338
Whether to rewrite all rendered doc pages, or only those with changes.
339+
source_dir:
340+
A directory where source files to be documented live. This is only necessary
341+
if you are not documenting a package, but collection of scripts. Use a "."
342+
to refer to the current directory.
339343
340344
"""
341345

@@ -377,6 +381,7 @@ def __init__(
377381
out_index: str = None,
378382
sidebar: "str | None" = None,
379383
rewrite_all_pages=False,
384+
source_dir: "str | None" = None,
380385
):
381386
self.layout = self.load_layout(sections=sections, package=package)
382387

@@ -392,6 +397,7 @@ def __init__(
392397
self.out_index = out_index
393398

394399
self.rewrite_all_pages = rewrite_all_pages
400+
self.source_dir = str(Path(source_dir).absolute()) if source_dir else None
395401

396402
def load_layout(self, sections: dict, package: str):
397403
# TODO: currently returning the list of sections, to make work with
@@ -414,6 +420,11 @@ def build(self, filter: str = "*"):
414420

415421
from quartodoc import blueprint, collect
416422

423+
if self.source_dir:
424+
import sys
425+
426+
sys.path.append(self.source_dir)
427+
417428
# shaping and collection ----
418429

419430
_log.info("Generating blueprint.")

0 commit comments

Comments
 (0)