module documentation

Implements the low-level algorithms Sphinx uses for the versioning of doctrees.

Unknown Field: copyright | |

Copyright 2007-2022 by the Sphinx team, see AUTHORS. | |

Unknown Field: license | |

BSD, see LICENSE for details. |

Constant | `IS_SPEEDUP` |
Undocumented |

Constant | `VERSIONING_RATIO` |
Undocumented |

Class | `UIDTransform` |
Add UIDs to doctree for versioning. |

Function | `add_uids` |
Add a unique id to every node in the `doctree` which matches the condition and yield the nodes. |

Function | `get_ratio` |
Return a "similarity ratio" (in percent) representing the similarity between the two strings where 0 is equal and anything above less than equal. |

Function | `levenshtein_distance` |
Return the Levenshtein edit distance between two strings a and b. |

Function | `merge_doctrees` |
Merge the `old` doctree with the `new` one while looking at nodes matching the `condition` . |

Function | `setup` |
Undocumented |

def add_uids(doctree, condition):

Add a unique id to every node in the

`doctree`

which matches the
condition and yield the nodes.Parameters | |

doctree:`Node` | A `docutils.nodes.document` instance. |

condition:`Any` | A callable which returns either True or False for a given node. |

Returns | |

`Iterator[` | Undocumented |

def get_ratio(old, new):

Return a "similarity ratio" (in percent) representing the similarity
between the two strings where 0 is equal and anything above less than equal.

Parameters | |

old:`str` | Undocumented |

new:`str` | Undocumented |

Returns | |

`float` | Undocumented |

def levenshtein_distance(a, b):

Return the Levenshtein edit distance between two strings *a* and *b*.

Parameters | |

a:`str` | Undocumented |

b:`str` | Undocumented |

Returns | |

`int` | Undocumented |

def merge_doctrees(old, new, condition):

Merge the `old`

doctree with the `new`

one while looking at nodes
matching the `condition`

.

Each node which replaces another one or has been added to the `new`

doctree
will be yielded.

Parameters | |

old:`Node` | Undocumented |

new:`Node` | Undocumented |

condition:`Any` | A callable which returns either True or False for a given node. |

Returns | |

`Iterator[` | Undocumented |