lektor-website/content/docs/api/build/context/contents.lr
David Baumgold a98b2fe9f9 Document Python 3 support
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.
2016-06-02 21:55:55 -07:00

30 lines
903 B
Markdown

title: Context
---
summary: Provides context information for the current build.
---
module: lektor.context
---
type: class
---
body:
When Lektor builds sources into finished build artifacts it performs many
operations in addition to just creating the end result. For instance it needs
to perform dependency tracking, it needs to remember that there might be
associated other artifacts and more. All this information is tracked on the
`Context` during a build of a single source. At a later point the builder
will look at the context to decide on further operations to perform.
The current context can be discovered by calling the [get_ctx :ref](../get-ctx/)
function which will return it. If there is no artifact build ongoing then
the return value will be `None`.
## Basic Example
```python
from lektor.context import get_ctx
ctx = get_ctx()
print('The current source is %s' % ctx.source)
```