Skip to content

Commit b9eb486

Browse files
authored
Merge pull request #23 from JSv4/docs/quickstart-docxodus-default
Update quickstart to feature DocxodusEngine; widen run_redline type hint
2 parents ffa5202 + 2381c56 commit b9eb486

2 files changed

Lines changed: 33 additions & 13 deletions

File tree

docs/quickstart.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
# Python-Redlines Quickstart
22

33
`python-redlines` wraps a C# comparison engine to produce tracked-change redline `.docx`
4-
files. This guide uses the `XmlPowerToolsEngine` (Open-XML-PowerTools); `DocxodusEngine`
5-
works the same way.
4+
files. This guide uses `DocxodusEngine` — the default and recommended engine.
5+
`XmlPowerToolsEngine` (legacy) shares the same call signature; the only behavioural
6+
difference is that it silently ignores the keyword arguments shown in Step 4.
67

78
### Step 0: Install
89

910
Install the core package plus the engine you want as an extra. No .NET SDK is needed —
1011
the engine binary is prebuilt and embedded in the wheel.
1112

1213
```commandline
13-
pip install python-redlines[ooxmlpowertools]
14+
pip install python-redlines[docxodus]
1415
```
1516

17+
Use `python-redlines[ooxmlpowertools]` for the legacy engine, or `python-redlines[all]`
18+
for both.
19+
1620
### Step 1: Import and Initialize the Wrapper
1721

1822
In your Python script or interactive session, import and initialize the wrapper:
1923

2024
```python
21-
from python_redlines.engines import XmlPowerToolsEngine
25+
from python_redlines import DocxodusEngine
2226

23-
wrapper = XmlPowerToolsEngine()
27+
wrapper = DocxodusEngine()
2428
```
2529

2630
### Step 2: Run Redlines
2731

28-
Use the `run_redline` method to compare documents. You can pass the paths of the `.docx` files or their byte content:
32+
Use the `run_redline` method to compare documents. You can pass the paths of the `.docx` files (as `str` or `pathlib.Path`) or their byte content:
2933

3034
```python
3135
# Example with file paths
@@ -37,12 +41,11 @@ with open('/path/to/original.docx', 'rb') as f:
3741
with open('/path/to/modified.docx', 'rb') as f:
3842
modified_bytes = f.read()
3943

40-
# This is a tuple, bytes @ element 0
44+
# Returns (redline_bytes, stdout, stderr)
4145
output = wrapper.run_redline('AuthorTag', original_bytes, modified_bytes)
4246
```
4347

44-
In both cases, `output` will contain the byte content of the resulting redline - a .docx with changes in tracked
45-
changes.
48+
In both cases, `output[0]` will contain the byte content of the resulting redline — a .docx with changes as Word tracked changes.
4649

4750
### Step 3: Handle the Output
4851

@@ -52,3 +55,20 @@ Process or save the output as needed. For example, to save the redline output to
5255
with open('/path/to/redline_output.docx', 'wb') as f:
5356
f.write(output[0])
5457
```
58+
59+
### Step 4: Tune the Comparison (optional, DocxodusEngine only)
60+
61+
`DocxodusEngine` accepts keyword arguments to control move detection, granularity, and
62+
more. See the [main README](../README.md#comparison-settings-docxodusengine-only) for
63+
the full table.
64+
65+
```python
66+
output = wrapper.run_redline(
67+
'AuthorTag', original_bytes, modified_bytes,
68+
detect_moves=True,
69+
simplify_move_markup=True, # required with detect_moves for Word compatibility
70+
detail_threshold=0.3,
71+
)
72+
```
73+
74+
`XmlPowerToolsEngine` silently ignores these kwargs — switch engines if you need them.

packages/core/src/python_redlines/engines.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ def _build_command(self, author_tag: str, original_path, modified_path, target_p
132132
"""
133133
return [self.extracted_binaries_path, author_tag, original_path, modified_path, target_path]
134134

135-
def run_redline(self, author_tag: str, original: Union[bytes, Path], modified: Union[bytes, Path], **kwargs) \
136-
-> Tuple[bytes, Optional[str], Optional[str]]:
135+
def run_redline(self, author_tag: str, original: Union[str, bytes, Path], modified: Union[str, bytes, Path],
136+
**kwargs) -> Tuple[bytes, Optional[str], Optional[str]]:
137137
"""
138-
Runs the redline binary. The 'original' and 'modified' arguments can be either bytes or file paths.
139-
Returns the redline output as bytes.
138+
Runs the redline binary. The 'original' and 'modified' arguments can be either bytes or file paths
139+
(as ``str`` or ``pathlib.Path``). Returns the redline output as bytes.
140140
141141
Additional keyword arguments are passed to _build_command() for engine-specific options.
142142
DocxodusEngine supports: detail_threshold, case_insensitive, detect_moves,

0 commit comments

Comments
 (0)