Repository: great-expectations/great_expectations

Issue:
Use cleaner solution for non-truncating division in python 2
Prefer `from __future__ import division` to `1.*x/y`


Discussion:
Done inline during improve_partitions push.

Resolving patch:
diff --git a/scripts/build_glossary_page.py b/scripts/build_glossary_page.py
new file mode 100644
--- /dev/null
+++ b/scripts/build_glossary_page.py
@@ -0,0 +1,36 @@
+import json
+
+
+def build_glossary_tuples(source_json_path):
+    # Open the source_json_path
+    with open(source_json_path) as json_file:
+        # Read the contents as a json
+        data = json.load(json_file)
+        # Convert to list of tuples containing ("term", "definition", "url")
+        data_list = [(x["term"], x["definition"], x["url"]) for x in data.values()]
+        # Order list alphabetically by "term"
+        data_list.sort(key=lambda y: y[0])
+        # return the ordered list.
+        return data_list
+
+
+def build_glossary_page(orderd_list_of_terms_tuples, glossary_file_path):
+    # Open the glossary page for editing
+    with open(glossary_file_path, "w") as glossary_file:
+        # Write the glossary page header
+        glossary_file.write('---\nid: glossary\ntitle: "Glossary of Terms"\n---\n\n')
+        # iterate the glossary list of tuples and write glossary entries.
+        for term, definition, url in orderd_list_of_terms_tuples:
+            glossary_file.write(f"[**{term}:**](./{url}.md) {definition}\n\n")
+
+
+def all_together_now(source_json_path, glossary_file_path):
+    list_of_terms_tuples = build_glossary_tuples(source_json_path)
+    build_glossary_page(list_of_terms_tuples, glossary_file_path)
+
+
+if __name__ == "__main__":
+    all_together_now(
+        source_json_path="../docs/term_tags/terms.json",
+        glossary_file_path="../docs/glossary.md",
+    )
diff --git a/scripts/docs_link_checker.py b/scripts/docs_link_checker.py
--- a/scripts/docs_link_checker.py
+++ b/scripts/docs_link_checker.py
@@ -66,7 +66,7 @@ def __init__(
         self._site_prefix = site_prefix.strip("/")
         self._skip_external = skip_external
 
-        markdown_link_regex = r"!?\[(.*?)\]\((.*?)\)"  # inline links, like [Description](link), images start with !
+        markdown_link_regex = r"!?\[(.*)\]\((.*?)\)"  # inline links, like [Description](link), images start with !
         self._markdown_link_pattern = re.compile(markdown_link_regex)
 
         external_link_regex = r"^https?:\/\/"  # links that start with http or https
@@ -289,9 +289,18 @@ def check_file(self, file: str) -> List[LinkReport]:
 
         for match in matches:
             report = self._check_link(match, file)
-            if report is not None:
+
+            if report:
                 result.append(report)
 
+            # sometimes the description may contain a reference to an image
+            nested_match = self._markdown_link_pattern.match(match.group(1))
+            if nested_match:
+                report = self._check_link(nested_match, file)
+
+                if report:
+                    result.append(report)
+
         return result
 
 
@@ -299,9 +308,9 @@ def check_file(self, file: str) -> List[LinkReport]:
 @click.option(
     "--path",
     "-p",
-    type=click.Path(exists=True, file_okay=False),
+    type=click.Path(exists=True, file_okay=True),
     default=".",
-    help="Path to markdown files to check",
+    help="Path to markdown file(s) to check",
 )
 @click.option(
     "--docs-root",
@@ -313,18 +322,13 @@ def check_file(self, file: str) -> List[LinkReport]:
 @click.option(
     "--site-prefix",
     "-s",
-    default="",
+    default=None,
     help="Top-most folder in the docs URL for resolving absolute paths",
 )
 @click.option("--skip-external", is_flag=True)
 def scan_docs(
     path: str, docs_root: Optional[str], site_prefix: str, skip_external: bool
 ) -> None:
-    # verify that our path is correct
-    if not os.path.isdir(path):
-        click.echo(f"Docs path: {path} is not a directory")
-        exit(1)
-
     if docs_root is None:
         docs_root = path
     elif not os.path.isdir(docs_root):
@@ -335,13 +339,20 @@ def scan_docs(
     result: List[LinkReport] = list()
     checker = LinkChecker(path, docs_root, site_prefix, skip_external)
 
-    for file in glob.glob(f"{path}/**/*.md", recursive=True):
-        report = checker.check_file(file)
-        if report:
-            result.extend(report)
+    if os.path.isdir(path):
+        # if the path is a directory, get all .md files within it
+        for file in glob.glob(f"{path}/**/*.md", recursive=True):
+            report = checker.check_file(file)
+            if report:
+                result.extend(report)
+    elif os.path.isfile(path):
+        # else we support checking one file at a time
+        result.extend(checker.check_file(path))
+    else:
+        click.echo(f"Docs path: {path} is not a directory or file")
+        exit(1)
 
     if result:
-        logger.info("%i broken links found", len(result))
         click.echo("----------------------------------------------")
         click.echo("------------- Broken Link Report -------------")
         click.echo("----------------------------------------------")
@@ -350,7 +361,6 @@ def scan_docs(
 
         exit(1)
     else:
-        logger.info("No broken links found")
         click.echo("No broken links found")
         exit(0)
 


Test patch: