MCPcopy Index your code
hub / github.com/huggingface/diffusers / diff_contains_doc_examples

Function diff_contains_doc_examples

utils/tests_fetcher.py:209–232  ·  view source on GitHub ↗

Check if the diff is only in code examples of the doc in a filename. Args: repo (`git.Repo`): A git repository (for instance the Transformers repo). branching_point (`str`): The commit reference of where to compare for the diff. filename (`str`): The filename where

(repo: Repo, branching_point: str, filename: str)

Source from the content-addressed store, hash-verified

207
208
209def diff_contains_doc_examples(repo: Repo, branching_point: str, filename: str) -> bool:
210 """
211 Check if the diff is only in code examples of the doc in a filename.
212
213 Args:
214 repo (`git.Repo`): A git repository (for instance the Transformers repo).
215 branching_point (`str`): The commit reference of where to compare for the diff.
216 filename (`str`): The filename where we want to know if the diff is only in codes examples.
217
218 Returns:
219 `bool`: Whether the diff is only in code examples of the doc or not.
220 """
221 folder = Path(repo.working_dir)
222 with checkout_commit(repo, branching_point):
223 with open(folder / filename, "r", encoding="utf-8") as f:
224 old_content = f.read()
225
226 with open(folder / filename, "r", encoding="utf-8") as f:
227 new_content = f.read()
228
229 old_content_clean = keep_doc_examples_only(old_content)
230 new_content_clean = keep_doc_examples_only(new_content)
231
232 return old_content_clean != new_content_clean
233
234
235def get_diff(repo: Repo, base_commit: str, commits: List[str]) -> List[str]:

Callers 1

get_diff_for_doctestingFunction · 0.85

Calls 2

checkout_commitFunction · 0.85
keep_doc_examples_onlyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…