Skip to content

Commit ea0b763

Browse files
authored
Merge pull request #269 from lf-lang/python-paths
Document Python path functions
2 parents 504e9db + 57e7f01 commit ea0b763

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

docs/reference/target-language-details.mdx

+23-3
Original file line numberDiff line numberDiff line change
@@ -2916,9 +2916,29 @@ FIXME: Details needed here.
29162916
</ShowIf>
29172917
<ShowIf py>
29182918

2919-
:::warning
2920-
FIXME: Details needed here.
2921-
:::
2919+
A few utility libraries are provided.
2920+
2921+
- **File Access**
2922+
2923+
- `lf.source_directory()`: Returns a string giving the full path to the directory containing the `.lf` file of the program.
2924+
- `lf.package_directory()`: Returns a string giving the full path to the directory that is the root of the project or package (normally, the directory above the `src` directory).
2925+
2926+
The above can be used to find supporting files, as shown in the following example:
2927+
2928+
```lf-py
2929+
target Python
2930+
preamble {=
2931+
import os
2932+
=}
2933+
main reactor {
2934+
state source_path = {= os.path.join(lf.source_directory(), "PythonPaths.lf") =}
2935+
reaction(startup) {=
2936+
file = open(self.source_path, "r");
2937+
print(file.read());
2938+
file.close();
2939+
=}
2940+
}
2941+
```
29222942

29232943
</ShowIf>
29242944
<ShowIf ts>

0 commit comments

Comments
 (0)