mirror of
https://github.com/lektor/lektor-website.git
synced 2025-01-31 22:41:29 +01:00
a98b2fe9f9
Now that Lektor supports Python 3, we need to document this support. This change is perhaps a bit extreme: it replaces all explicit references to Python 2.7 with explicit references to Python 3.5. However, it's a good start, and it can and should be reviewed before being merged.
26 lines
653 B
Markdown
26 lines
653 B
Markdown
title: gather_dependencies
|
|
---
|
|
summary: Can collect dependencies for a code block.
|
|
---
|
|
type: method
|
|
---
|
|
signature: func
|
|
---
|
|
body:
|
|
|
|
As code is executing in the context of the build process Lektor will
|
|
automatically track dependencies. However in some cases it might be
|
|
useful for a plugin to know exactly which dependencies are recorded.
|
|
|
|
In this case this method can be used as a context manager. Whenever Lektor
|
|
encounters a dependency it will invoke the passed function.
|
|
|
|
## Example
|
|
|
|
```python
|
|
deps = set()
|
|
with get_ctx().gather_dependencies(deps.add):
|
|
items = pad.query('/path/to/some/pages').all()
|
|
print('The dependencies are: %s' % deps)
|
|
```
|