11#!/usr/bin/env python3
22import argparse
3+ import glob
34import json
45import logging
56import os
6- import glob
77
8- from components .syntax import Command
98from components .markdown import Markdown
9+ from components .syntax import Command
1010
1111
1212def parse_args () -> argparse .Namespace :
@@ -21,6 +21,7 @@ def parse_args() -> argparse.Namespace:
2121 help = 'Directory to save railroad diagram SVG files' )
2222 return parser .parse_args ()
2323
24+
2425def generate_railroad_diagrams (commands_data : dict , output_dir : str ) -> None :
2526 """Generate railroad diagrams for all commands."""
2627 try :
@@ -63,10 +64,35 @@ def generate_railroad_diagrams(commands_data: dict, output_dir: str) -> None:
6364 force = True # Force reconfiguration in case logging was already configured
6465 )
6566
66- # Load all commands_* .json files
67+ # Load all commands_core .json and filter out stubbed commands
6768 all_commands = {}
68- command_files = glob .glob ('data/commands_*.json' )
6969
70+ FILTER_PREFIXES = [
71+ "BF." ,
72+ "CF." ,
73+ "CMS." ,
74+ "JSON." ,
75+ "FT." ,
76+ "_FT." ,
77+ "SEARCH." ,
78+ "TDIGEST." ,
79+ "TIMESERIES." ,
80+ "TOPK." ,
81+ "TS." ,
82+ ]
83+
84+ logging .info ("Loading commands from data/commands_core.json" )
85+ with open ('data/commands_core.json' , 'r' ) as f :
86+ data = json .load (f )
87+
88+ filtered = {
89+ key : value
90+ for key , value in data .items ()
91+ if not key .startswith (tuple (FILTER_PREFIXES ))
92+ }
93+ all_commands .update (filtered )
94+
95+ command_files = glob .glob ('data/commands_r*.json' )
7096 for command_file in command_files :
7197 logging .info (f"Loading commands from { command_file } " )
7298 with open (command_file , 'r' ) as f :
@@ -95,7 +121,6 @@ def generate_railroad_diagrams(commands_data: dict, output_dir: str) -> None:
95121 md .fm_data ['railroad_diagram' ] = railroad_file .replace ('static/' , '/' )
96122
97123 md .fm_data .update ({
98- 'syntax_str' : str (c ),
99124 'syntax_fmt' : sf ,
100125 })
101126 md .persist ()
0 commit comments