Skip to content

Commit d027494

Browse files
committed
- Restore docs autorefs as explained in mkdocstrings/mkdocstrings#226 (comment).
1 parent 25b6626 commit d027494

File tree

6 files changed

+62
-33
lines changed

6 files changed

+62
-33
lines changed

copier/main.py

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,18 @@ class Worker:
7474
src_path: Optional[str] = None
7575
"""String that can be resolved to a template path, be it local or remote.
7676
77-
See [Template.url][copier.template.Template.url] for more details.
77+
See [Template.url][copier.template.Template.url].
7878
79-
If it is `None`, then it means that you are [updating a
80-
project](../updating.md), and the original `src_path` will be obtained from
81-
[the answers file](../configuring.md#the-answers-file).
79+
If it is `None`, then it means that you are [updating a project][updating-a-project],
80+
and the original `src_path` will be obtained from
81+
[the answers file][the-copier-answersyml-file].
8282
"""
8383

8484
dst_path: Path = field(default=".")
8585
"""Destination path where to render the subproject."""
8686

8787
answers_file: Optional[RelativePath] = None
88-
"""Indicates the path for [the answers file](../configuring.md#the-answers-file).
88+
"""Indicates the path for [the answers file][the-copier-answersyml-file].
8989
9090
The path must be relative to [dst_path][copier.main.Worker.dst_path].
9191
@@ -102,38 +102,46 @@ class Worker:
102102
exclude: StrSeq = ()
103103
"""Additional file exclusion patterns.
104104
105-
See [copier.template.Template.exclude][] for more details.
105+
See [exclude][].
106106
"""
107107

108108
use_prereleases: bool = False
109109
"""Consider prereleases when detecting the *latest* one?
110110
111-
See [copier.template.Template.use_prereleases][].
111+
See [use_prereleases][].
112112
113113
Useless if specifying a [vcs_ref][copier.main.Worker.vcs_ref].
114114
"""
115115

116116
skip_if_exists: StrSeq = ()
117117
"""Additional file skip patterns.
118118
119-
See [copier.template.Template.skip_if_exists][] for more details.
119+
See [skip_if_exists][].
120120
"""
121121

122122
cleanup_on_error: bool = True
123123
"""Delete [dst_path][copier.main.Worker.dst_path] if there's an error?
124124
125-
It only applies when [dst_path][copier.main.Worker.dst_path] was created by
126-
this process. Preexisting subprojects are never cleaned up.
125+
See [cleanup_on_error][].
127126
"""
128127

129128
force: bool = False
130-
"""When `True`, disable all user interactions."""
129+
"""When `True`, disable all user interactions.
130+
131+
See [force][].
132+
"""
131133

132134
pretend: bool = False
133-
"""When `True`, produce no real rendering."""
135+
"""When `True`, produce no real rendering.
136+
137+
See [pretend][].
138+
"""
134139

135140
quiet: bool = False
136-
"""When `True`, disable all output."""
141+
"""When `True`, disable all output.
142+
143+
See [quiet][].
144+
"""
137145

138146
def _answers_to_remember(self) -> Mapping:
139147
"""Get only answers that will be remembered in the copier answers file."""
@@ -533,6 +541,8 @@ def run_copy(self) -> None:
533541
created. Otherwise, [src_path][copier.main.Worker.src_path] be rendered
534542
directly into it, without worrying about evolving what was there
535543
already.
544+
545+
See [generating a project][generating-a-project].
536546
"""
537547
was_existing = self.subproject.local_abspath.exists()
538548
if not self.quiet:
@@ -559,20 +569,9 @@ def run_copy(self) -> None:
559569
print("") # padding space
560570

561571
def run_update(self) -> None:
562-
"""Update the subproject.
563-
564-
Before running this, [dst_path][copier.main.Worker.dst_path] must exist
565-
and must contain an already-applied template, with a valid [copier
566-
answers](../configuring.md#the-answers-file) file that points to a
567-
versioned git template.
568-
569-
Copier will download the old template, render it with last answers,
570-
download the latest version, apply it to the current subproject, and
571-
compare both renders to apply a smart diff that, in practice, applies
572-
the evolution of the template dynamically over the subproject.
572+
"""Update a subproject that was already generated.
573573
574-
In case of conflicts, `.rej` files will be dropped, next to the
575-
conflicting ones.
574+
See [updating a project][updating-a-project].
576575
"""
577576
# Check all you need is there
578577
if self.subproject.vcs != "git":

copier/subproject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Subproject:
2929
"""Absolute path on local disk pointing to the subproject root folder."""
3030

3131
answers_relpath: Path = Path(".copier-answers.yml")
32-
"""Relative path to [the answers file](../configuring.md#the-answers-file)."""
32+
"""Relative path to [the answers file][the-copier-answersyml-file]."""
3333

3434
def is_dirty(self) -> bool:
3535
"""Indicates if the local template root is dirty.

copier/template.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def verify_minimum_version(version_str: str) -> None:
7373

7474
@dataclass
7575
class Template:
76-
"""Object that represents a template and its current state."""
76+
"""Object that represents a template and its current state.
77+
78+
See [configuring a template][configuring-a-template].
79+
"""
7780

7881
url: str
7982
"""Absolute origin that points to the template.

copier/user_data.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class AnswersMap:
6666
init: AnyByStrDict = field(default_factory=dict)
6767
"""Answers provided on init.
6868
69-
This will hold those answers that come from `--data` in CLI mode, or
70-
[copier.main.Worker.data][] in API mode.
69+
This will hold those answers that come from `--data` in
70+
CLI mode ([copier.main.Worker.data][] in API mode).
7171
"""
7272

7373
metadata: AnyByStrDict = field(default_factory=dict)
@@ -77,7 +77,13 @@ class AnswersMap:
7777
"""
7878

7979
last: AnyByStrDict = field(default_factory=dict)
80+
"""Data from [the answers file][the-copier-answersyml-file]."""
81+
8082
default: AnyByStrDict = field(default_factory=dict)
83+
"""Default data from the template.
84+
85+
See [copier.template.Template.default_answers][].
86+
"""
8187

8288
@cached_property
8389
def combined(self) -> t_ChainMap[str, Any]:
@@ -342,7 +348,7 @@ def load_yaml_data(conf_path: Path, quiet: bool = False) -> AnyByStrDict:
342348
"""Load the `copier.yml` file.
343349
344350
This is like a simple YAML load, but applying all specific quirks needed
345-
for [the `copier.yml` file](../configuring.md#the-copieryml-file).
351+
for [the `copier.yml` file][the-copieryml-file].
346352
347353
For example, it supports the `!include` tag with glob includes, and
348354
merges multiple sections.

copier/vcs.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
from .types import OptBool, OptStr, StrOrPath
1212

13-
__all__ = ("get_repo", "clone")
14-
1513
GIT_PREFIX = ("git@", "git://", "git+")
1614
GIT_POSTFIX = (".git",)
1715
REPLACEMENTS = (
@@ -40,6 +38,19 @@ def is_git_bundle(path: Path) -> bool:
4038

4139

4240
def get_repo(url: str) -> OptStr:
41+
"""Transforms `url` into a git-parseable origin URL.
42+
43+
Args:
44+
url:
45+
Valid examples:
46+
47+
- gh:copier-org/copier
48+
- gl:copier-org/copier
49+
- [email protected]:copier-org/copier.git
50+
- git+https://mywebsiteisagitrepo.example.com/
51+
- /local/path/to/git/repo
52+
- /local/path/to/git/bundle/file.bundle
53+
"""
4354
for pattern, replacement in REPLACEMENTS:
4455
url = re.sub(pattern, replacement, url)
4556
url_path = Path(url)
@@ -86,6 +97,15 @@ def checkout_latest_tag(local_repo: StrOrPath, use_prereleases: OptBool = False)
8697

8798

8899
def clone(url: str, ref: OptStr = None) -> str:
100+
"""Clone repo into some temporary destination.
101+
102+
Args:
103+
url:
104+
Git-parseable URL of the repo. As returned by
105+
[get_repo][copier.vcs.get_repo].
106+
ref:
107+
Reference to checkout. For Git repos, defaults to `HEAD`.
108+
"""
89109
location = tempfile.mkdtemp(prefix=f"{__name__}.clone.")
90110
git("clone", "--no-checkout", url, location)
91111
with local.cwd(location):

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ markdown_extensions:
4141
permalink: true
4242

4343
plugins:
44+
- autorefs
4445
- search
4546
- mermaid2:
4647
arguments:

0 commit comments

Comments
 (0)