Skip to content

Commit 0ff2d50

Browse files
authored
Added API_README to docs (#1146)
1 parent 2875b45 commit 0ff2d50

21 files changed

+5023
-717
lines changed

API_README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ osxphotos provides several useful helper functions to make it easy to build simp
5757
Here's a simple example showing how to use the `query_command` decorator to implement a simple command line tool. The `query_command` decorator turns your function into a full-fledged [Click](https://palletsprojects.com/p/click/) command line app that can be run via `osxphotos run example.py` or `python example.py` if you have pip installed osxphotos. Your command will include all the query options available in `osxphotos query` as command line options as well as `--verbose` and other convenient options.
5858

5959
<!--[[[cog
60-
cog.out("```python\n")
60+
cog.out("\n```python\n")
6161
with open("examples/cli_example_1.py", "r") as f:
6262
cog.out(f.read())
6363
cog.out("```\n")
6464
]]]-->
65+
6566
```python
6667
"""Sample query command for osxphotos
6768
@@ -136,11 +137,12 @@ if __name__ == "__main__":
136137
Here is a more advanced example that shows how to implement a script with a "dry run" and "resume" capability that preserves state between runs. Using the built-in helpers allows you to implement complex behavior in just a few lines of code.
137138

138139
<!--[[[cog
139-
cog.out("```python\n")
140+
cog.out("\n```python\n")
140141
with open("examples/cli_example_2.py", "r") as f:
141142
cog.out(f.read())
142143
cog.out("```\n")
143144
]]]-->
145+
144146
```python
145147
"""Sample query command for osxphotos
146148
@@ -308,11 +310,12 @@ if __name__ == "__main__":
308310
In addition to the `query_command` decorator, you can also use the `selection_command` decorator to implement a command that operates on the current selection in Photos.
309311

310312
<!--[[[cog
311-
cog.out("```python\n")
313+
cog.out("\n```python\n")
312314
with open("examples/cli_example_3.py", "r") as f:
313315
cog.out(f.read())
314316
cog.out("```\n")
315317
]]]-->
318+
316319
```python
317320
"""Sample query command for osxphotos
318321
@@ -2242,8 +2245,9 @@ To get the path of every raw photo, whether it's a single raw photo or a raw+JPE
22422245

22432246
<!--[[[cog
22442247
from osxphotos.phototemplate import get_template_help
2245-
cog.out(get_template_help())
2248+
cog.out("\n"+get_template_help())
22462249
]]]-->
2250+
22472251
<!-- Generated by cog: see phototemplate.cog.md -->
22482252

22492253
The templating system converts one or template statements, written in osxphotos metadata templating language, to one or more rendered values using information from the photo being processed.
@@ -2408,8 +2412,9 @@ The following template field substitutions are availabe for use the templating s
24082412

24092413
<!--[[[cog
24102414
from osxphotos.phototemplate import get_template_field_table
2411-
cog.out(get_template_field_table())
2415+
cog.out("\n"+get_template_field_table()+"\n")
24122416
]]]-->
2417+
24132418
| Field | Description |
24142419
|--------------|-------------|
24152420
|{name}|Current filename of the photo|

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,18 @@ Options:
14481448
full path of all exported files to the file
14491449
'exported.txt'. You can run more than one
14501450
command by repeating the '--post-command'
1451-
option with different arguments. See Post
1452-
Command below.
1451+
option with different arguments. See also
1452+
--post-command-error and --post-function.See
1453+
Post Command below.
1454+
--post-command-error ACTION Specify either `continue` or `break` for
1455+
ACTION to control behavior when a post-command
1456+
fails. If `continue`, osxphotos will log the
1457+
error and continue processing. If `break`,
1458+
osxphotos will stop processing any additional
1459+
--post-command commands for the current photo
1460+
but will continue with the export. Without
1461+
--post-command-error, osxphotos will abort the
1462+
export if a post-command encounters an error.
14531463
--post-function filename.py::function
14541464
Run function on exported files. Use this in
14551465
format: --post-function filename.py::function

build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ python3 utils/generate_template_docs.py
3030
m2r2 docsrc/source/template_help.md
3131
rm docsrc/source/template_help.md
3232

33+
echo "Copying API_README.md to docsrc/source/api_readme.md"
34+
rm docsrc/source/api_readme.rst
35+
cp API_README.md docsrc/source/api_readme.md
36+
m2r2 docsrc/source/api_readme.md
37+
rm docsrc/source/api_readme.md
38+
3339
# build docs
3440
echo "Building docs"
3541
(cd docsrc && make github && make pdf)

0 commit comments

Comments
 (0)