def generate_readme_for_pack_content_item(self, yml_path: str, is_contribution: bool = False ) -> None: """ Runs the demisto-sdk's generate-docs command on a pack content item Args: yml_path: str: Content item yml path. is_contribution: bool: Check if the content item is a new integration contribution or not. """ file_type = find_type(yml_path) file_type = file_type.value if file_type else file_type if file_type == 'integration': generate_integration_doc(yml_path, is_contribution=is_contribution) if file_type == 'script': generate_script_doc(input_path=yml_path, examples=[]) if file_type == 'playbook': generate_playbook_doc(yml_path) dir_output = os.path.dirname(os.path.realpath(yml_path)) if file_type == 'playbook': readme_path = yml_path.replace('.yml', '_README.md') else: readme_path = os.path.join(dir_output, 'README.md') self.readme_files.append(readme_path)
def generate_doc(**kwargs): input_path = kwargs.get('input') output_path = kwargs.get('output') # validate inputs if input_path and not os.path.isfile(input_path): print_error(F'Input file {input_path} was not found.') return 1 if not input_path.lower().endswith('.yml'): print_error(F'Input {input_path} is not a valid yml file.') return 1 if output_path and not os.path.isdir(output_path): print_error(F'Output directory {output_path} was not found.') return 1 file_type = find_type(kwargs.get('input', '')) if file_type not in ["integration", "script", "playbook"]: print_error(F'File is not an Integration, Script or a Playbook.') return 1 print(f'Start generating {file_type} documentation...') if file_type == 'integration': return generate_integration_doc(**kwargs) elif file_type == 'script': return generate_script_doc(**kwargs) elif file_type == 'playbook': return generate_playbook_doc(**kwargs) else: print_error(f'File type {file_type} is not supported.') return 1
def generate_readme_for_pack_content_item(self, yml_path: str) -> None: """ Runs the demisto-sdk's generate-docs command on a pack content item Args: yml_path: str: Content item yml path. """ file_type = find_type(yml_path) file_type = file_type.value if file_type else file_type if file_type == 'integration': generate_integration_doc(yml_path) if file_type == 'script': generate_script_doc(input_path=yml_path, examples=[]) if file_type == 'playbook': generate_playbook_doc(yml_path) dir_output = os.path.dirname(os.path.realpath(yml_path)) readme_path = os.path.join(dir_output, 'README.md') self.readme_files.append(readme_path)
def generate_doc(**kwargs): input_path = kwargs.get('input') output_path = kwargs.get('output') command = kwargs.get('command') examples = kwargs.get('examples') permissions = kwargs.get('permissions') limitations = kwargs.get('limitations') insecure = kwargs.get('insecure') verbose = kwargs.get('verbose') # validate inputs if input_path and not os.path.isfile(input_path): print_error(F'Input file {input_path} was not found.') return 1 if not input_path.lower().endswith('.yml'): print_error(F'Input {input_path} is not a valid yml file.') return 1 if output_path and not os.path.isdir(output_path): print_error(F'Output directory {output_path} was not found.') return 1 if command: if output_path and (not os.path.isfile(os.path.join(output_path, "README.md")))\ or (not output_path)\ and (not os.path.isfile(os.path.join(os.path.dirname(os.path.realpath(input_path)), "README.md"))): print_error("The `command` argument must be presented with existing `README.md` docs.") return 1 file_type = find_type(kwargs.get('input', '')) if file_type not in ["integration", "script", "playbook"]: print_error('File is not an Integration, Script or a Playbook.') return 1 print(f'Start generating {file_type} documentation...') if file_type == 'integration': use_cases = kwargs.get('use_cases') command_permissions = kwargs.get('command_permissions') return generate_integration_doc(input=input_path, output=output_path, use_cases=use_cases, examples=examples, permissions=permissions, command_permissions=command_permissions, limitations=limitations, insecure=insecure, verbose=verbose, command=command) elif file_type == 'script': return generate_script_doc(input=input_path, output=output_path, examples=examples, permissions=permissions, limitations=limitations, insecure=insecure, verbose=verbose) elif file_type == 'playbook': return generate_playbook_doc(input=input_path, output=output_path, permissions=permissions, limitations=limitations, verbose=verbose) else: print_error(f'File type {file_type} is not supported.') return 1