11import os
22from pathlib import Path
3- import yaml # type: ignore
3+ import yaml # type: ignore
44from invoke import Context , task # type: ignore
55
66# If no version is indicated, we will take the latest
1313
1414METADATA_FILE = CURRENT_DIRECTORY .parent / ".metadata.yml"
1515
16+
1617def _parse_and_load_extensions (
1718 context : Context , extensions_path : Path , allowed_to_fail : bool
1819) -> None :
@@ -85,10 +86,10 @@ def generate_readme(schema, extension_dir: Path) -> list:
8586 # f"{schema.get('description', '')}\n",
8687 # ]
8788
88- description = schema .get (' description' , '' )
89+ description = schema .get (" description" , "" )
8990 content = [
9091 f"# { schema .get ('name' , '' )} \n " ,
91- f"{ description } \n " if not description .endswith (' \n ' ) else description
92+ f"{ description } \n " if not description .endswith (" \n " ) else description ,
9293 ]
9394
9495 if dependencies := schema .get ("dependencies" , []):
@@ -99,12 +100,28 @@ def generate_readme(schema, extension_dir: Path) -> list:
99100
100101 def format_table (headers : list , rows : list ):
101102 """Generate a Markdown table."""
103+
102104 def escape_markdown (text : str ) -> str :
103105 # Escape special markdown characters
104- special_chars = ['|' , '_' , '*' , '`' , '[' , ']' , '(' , ')' , '#' , '+' , '-' , '.' , '!' , '$' ]
106+ special_chars = [
107+ "|" ,
108+ "_" ,
109+ "*" ,
110+ "`" ,
111+ "[" ,
112+ "]" ,
113+ "(" ,
114+ ")" ,
115+ "#" ,
116+ "+" ,
117+ "-" ,
118+ "." ,
119+ "!" ,
120+ "$" ,
121+ ]
105122
106123 for char in special_chars :
107- text = text .replace (char , f' \\ { char } ' )
124+ text = text .replace (char , f" \\ { char } " )
108125 return text
109126
110127 table = f"\n | { ' | ' .join (headers )} |\n "
@@ -155,10 +172,10 @@ def generate_node_data(node: dict):
155172 if node .get ("order_by" ) or node .get ("uniqueness_constraints" ):
156173 node_markdown .append ("#### Ordering and Constraints\n " )
157174 node_markdown .append (
158- f"- **Order By:**{ ', ' .join (node .get ('order_by' , []))} "
175+ f"- **Order By:**{ ', ' .join (node .get ('order_by' , []))} "
159176 )
160177 node_markdown .append (
161- f"- **Uniqueness Constraints:**{ ', ' .join ([' + ' .join (c ) for c in node .get ('uniqueness_constraints' , [])])} \n "
178+ f"- **Uniqueness Constraints:**{ ', ' .join ([' + ' .join (c ) for c in node .get ('uniqueness_constraints' , [])])} \n "
162179 )
163180 # node_markdown.append("\n")
164181
@@ -224,7 +241,9 @@ def build(context: Context) -> None:
224241 consolidated_doc = schema_docs_dir / "schema-library.mdx"
225242
226243 all_content = []
227- all_content .append ("---\n title: Schema Library Documentation\n ---\n <!-- markdownlint-disable-file MD025 -->\n " )
244+ all_content .append (
245+ "---\n title: Schema Library Documentation\n ---\n <!-- markdownlint-disable-file MD025 -->\n "
246+ )
228247
229248 with open (METADATA_FILE , "r" , encoding = "utf-8" ) as f :
230249 schema = yaml .safe_load (f )
@@ -261,4 +280,3 @@ def build(context: Context) -> None:
261280 # generate_readme(schema[str(path)], path)
262281 # except KeyError:
263282 # print(f"Schema `{path}` is not added to the {METADATA_FILE} file")
264-
0 commit comments