Top-level function. Generate a diagram based on source code. Can generate either a dotfile or an image. :param list[str] raw_source_paths: file or directory paths :param str|file output_file: path to the output file. SVG/PNG will generate an image. :param str language: input la
(raw_source_paths, output_file, language=None, hide_legend=True,
exclude_namespaces=None, exclude_functions=None,
include_only_namespaces=None, include_only_functions=None,
no_grouping=False, no_trimming=False, skip_parse_errors=False,
lang_params=None, subset_params=None, level=logging.INFO)
| 669 | |
| 670 | |
| 671 | def code2flow(raw_source_paths, output_file, language=None, hide_legend=True, |
| 672 | exclude_namespaces=None, exclude_functions=None, |
| 673 | include_only_namespaces=None, include_only_functions=None, |
| 674 | no_grouping=False, no_trimming=False, skip_parse_errors=False, |
| 675 | lang_params=None, subset_params=None, level=logging.INFO): |
| 676 | """ |
| 677 | Top-level function. Generate a diagram based on source code. |
| 678 | Can generate either a dotfile or an image. |
| 679 | |
| 680 | :param list[str] raw_source_paths: file or directory paths |
| 681 | :param str|file output_file: path to the output file. SVG/PNG will generate an image. |
| 682 | :param str language: input language extension |
| 683 | :param bool hide_legend: Omit the legend from the output |
| 684 | :param list exclude_namespaces: List of namespaces to exclude |
| 685 | :param list exclude_functions: List of functions to exclude |
| 686 | :param list include_only_namespaces: List of namespaces to include |
| 687 | :param list include_only_functions: List of functions to include |
| 688 | :param bool no_grouping: Don't group functions into namespaces in the final output |
| 689 | :param bool no_trimming: Don't trim orphaned functions / namespaces |
| 690 | :param bool skip_parse_errors: If a language parser fails to parse a file, skip it |
| 691 | :param lang_params LanguageParams: Object to store lang-specific params |
| 692 | :param subset_params SubsetParams: Object to store subset-specific params |
| 693 | :param int level: logging level |
| 694 | :rtype: None |
| 695 | """ |
| 696 | start_time = time.time() |
| 697 | |
| 698 | if not isinstance(raw_source_paths, list): |
| 699 | raw_source_paths = [raw_source_paths] |
| 700 | lang_params = lang_params or LanguageParams() |
| 701 | |
| 702 | exclude_namespaces = exclude_namespaces or [] |
| 703 | assert isinstance(exclude_namespaces, list) |
| 704 | exclude_functions = exclude_functions or [] |
| 705 | assert isinstance(exclude_functions, list) |
| 706 | include_only_namespaces = include_only_namespaces or [] |
| 707 | assert isinstance(include_only_namespaces, list) |
| 708 | include_only_functions = include_only_functions or [] |
| 709 | assert isinstance(include_only_functions, list) |
| 710 | |
| 711 | logging.basicConfig(format="Code2Flow: %(message)s", level=level) |
| 712 | |
| 713 | sources, language = get_sources_and_language(raw_source_paths, language) |
| 714 | |
| 715 | output_ext = None |
| 716 | if isinstance(output_file, str): |
| 717 | assert '.' in output_file, "Output filename must end in one of: %r." % set(VALID_EXTENSIONS) |
| 718 | output_ext = output_file.rsplit('.', 1)[1] or '' |
| 719 | assert output_ext in VALID_EXTENSIONS, "Output filename must end in one of: %r." % \ |
| 720 | set(VALID_EXTENSIONS) |
| 721 | |
| 722 | final_img_filename = None |
| 723 | if output_ext and output_ext in IMAGE_EXTENSIONS: |
| 724 | if not is_installed('dot') and not is_installed('dot.exe'): |
| 725 | raise AssertionError( |
| 726 | "Can't generate a flowchart image because neither `dot` nor " |
| 727 | "`dot.exe` was found. Either install graphviz (see the README) " |
| 728 | "or, if you just want an intermediate text file, set your --output " |