Skip to content

Commit 5b243e7

Browse files
committed
Add documentation
1 parent 410b560 commit 5b243e7

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

docs/reference/language.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ other) groupings.
130130

131131
---8<-- 'includes/generated_docs/language__measures.md'
132132

133+
---
134+
133135

134136
## Parameters
135137

@@ -139,3 +141,10 @@ from the [command line](cli.md#generate-dataset.user_args).
139141
---8<-- 'includes/generated_docs/language__parameters.md'
140142

141143
---
144+
145+
146+
## Permissions
147+
148+
---8<-- 'includes/generated_docs/language__permissions.md'
149+
150+
---

ehrql/docs/language.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def build_language():
110110
"parameters": {
111111
"get_parameter": namespace["get_parameter"],
112112
},
113+
"permissions": {
114+
"claim_permissions": namespace["claim_permissions"],
115+
},
113116
}
114117

115118
# Check that the documentation is complete

ehrql/permissions.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,24 @@ class EHRQLPermissionError(Exception):
1616

1717

1818
def claim_permissions(*permissions):
19+
"""
20+
Some tables and features in ehrQL can only be accessed with specific permission set
21+
by the OpenSAFELY team. These restrictions are only enforced when working with real
22+
data, however to avoid confusion we also check them when working with dummy data.
23+
24+
When using dummy data you can grant yourself any permission using the
25+
`claim_permissions()` function. For example:
26+
27+
from ehrql import claim_permissions
28+
29+
claim_permissions("some_permission", "another_permission")
30+
31+
This can go anywhere in your dataset or measure definition file.
32+
33+
This will allow you to develop your ehrQL code locally. But please **note that you
34+
will only be able to run against real data if you have had the necessary permissions
35+
granted by the OpenSAFELY team**.
36+
"""
1937
for permission in permissions:
2038
# Use dictionary as convenient ordered set
2139
CLAIMED_PERMISSIONS[permission] = True

tests/unit/test_docs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def test_render(tmp_path):
5656
"language__functions.md",
5757
"language__measures.md",
5858
"language__parameters.md",
59+
"language__permissions.md",
5960
"language__series.md",
6061
"schemas",
6162
"schemas.md",

0 commit comments

Comments
 (0)