()
| 131 | |
| 132 | |
| 133 | def update_docs(): |
| 134 | md_files = [p for p in bbot_code_dir.glob("**/*.md") if p.is_file()] |
| 135 | |
| 136 | def update_md_files(keyword, s): |
| 137 | for file in md_files: |
| 138 | find_replace_file(file, keyword, s) |
| 139 | |
| 140 | def update_individual_module_options(): |
| 141 | regex = re.compile("BBOT MODULE OPTIONS ([A-Z_]+)") |
| 142 | for file in md_files: |
| 143 | with open(file) as f: |
| 144 | content = f.read() |
| 145 | for match in regex.finditer(content): |
| 146 | module_name = match.groups()[0].lower() |
| 147 | bbot_module_options_table = DEFAULT_PRESET.module_loader.modules_options_table(modules=[module_name]) |
| 148 | find_replace_file(file, f"BBOT MODULE OPTIONS {module_name.upper()}", bbot_module_options_table) |
| 149 | |
| 150 | # Example commands |
| 151 | bbot_example_commands = [] |
| 152 | for title, description, command in DEFAULT_PRESET.args.scan_examples: |
| 153 | example = "" |
| 154 | example += f"**{title}:**\n\n" |
| 155 | # example += f"{description}\n" |
| 156 | example += f"```bash\n# {description}\n{command}\n```" |
| 157 | bbot_example_commands.append(example) |
| 158 | bbot_example_commands = "\n\n".join(bbot_example_commands) |
| 159 | assert len(bbot_example_commands.splitlines()) > 10 |
| 160 | update_md_files("BBOT EXAMPLE COMMANDS", bbot_example_commands) |
| 161 | |
| 162 | # Help output |
| 163 | bbot_help_output = DEFAULT_PRESET.args.parser.format_help().replace("docs.py", "bbot") |
| 164 | bbot_help_output = f"```text\n{bbot_help_output}\n```" |
| 165 | assert len(bbot_help_output.splitlines()) > 50 |
| 166 | update_md_files("BBOT HELP OUTPUT", bbot_help_output) |
| 167 | |
| 168 | # BBOT events |
| 169 | bbot_event_table = DEFAULT_PRESET.module_loader.events_table() |
| 170 | assert len(bbot_event_table.splitlines()) > 10 |
| 171 | update_md_files("BBOT EVENTS", bbot_event_table) |
| 172 | |
| 173 | # BBOT modules |
| 174 | bbot_module_table = DEFAULT_PRESET.module_loader.modules_table(include_author=True, include_created_date=True) |
| 175 | assert len(bbot_module_table.splitlines()) > 50 |
| 176 | update_md_files("BBOT MODULES", bbot_module_table) |
| 177 | |
| 178 | # BBOT output modules |
| 179 | bbot_output_module_table = DEFAULT_PRESET.module_loader.modules_table( |
| 180 | mod_type="output", include_author=True, include_created_date=True |
| 181 | ) |
| 182 | assert len(bbot_output_module_table.splitlines()) > 10 |
| 183 | update_md_files("BBOT OUTPUT MODULES", bbot_output_module_table) |
| 184 | |
| 185 | # BBOT universal module options |
| 186 | from bbot.scanner.preset.args import universal_module_options |
| 187 | |
| 188 | universal_module_options_table = "" |
| 189 | for option, description in universal_module_options.items(): |
| 190 | universal_module_options_table += f"**{option}**: {description}\n" |
searching dependent graphs…