Skip to content

Commit

Permalink
Document Python path functions
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardalee committed Jun 25, 2024
1 parent 5c1c9d9 commit 57e7f01
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions docs/reference/target-language-details.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2916,9 +2916,29 @@ FIXME: Details needed here.
</ShowIf>
<ShowIf py>

:::warning
FIXME: Details needed here.
:::
A few utility libraries are provided.

- **File Access**

- `lf.source_directory()`: Returns a string giving the full path to the directory containing the `.lf` file of the program.
- `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).

The above can be used to find supporting files, as shown in the following example:

```lf-py
target Python
preamble {=
import os
=}
main reactor {
state source_path = {= os.path.join(lf.source_directory(), "PythonPaths.lf") =}
reaction(startup) {=
file = open(self.source_path, "r");
print(file.read());
file.close();
=}
}
```

</ShowIf>
<ShowIf ts>
Expand Down

0 comments on commit 57e7f01

Please sign in to comment.