# Path: anchorhub/builtin/github/collector.py
# def make_github_markdown_collector(opts):
#     """
#     Creates a Collector object used for parsing Markdown files with a GitHub
#     style anchor transformation
# 
#     :param opts: Namespace object of options for the AnchorHub program.
#     Usually created from command-line arguments. It must contain a
#     'wrapper_regex' attribute
#     :return: a Collector object designed for collecting tag/anchor pairs from
#     Markdown files using GitHub style anchors
#     """
#     assert hasattr(opts, 'wrapper_regex')
#     atx = MarkdownATXCollectorStrategy(opts)
#     setext = MarkdownSetextCollectorStrategy(opts)
#     code_block_switch = ghswitches.code_block_switch
# 
#     strategies = [atx, setext]
#     switches = [code_block_switch]
# 
#     return Collector(converter.create_anchor_from_header, strategies,
#                      switches=switches)
# 
# Path: anchorhub/builtin/github/writer.py
# def make_github_markdown_writer(opts):
#     """
#     Creates a Writer object used for parsing and writing Markdown files with
#     a GitHub style anchor transformation
# 
#     opts is a namespace object containing runtime options. It should
#     generally include the following attributes:
# 
#     * 'open':   a string corresponding to the opening portion of the wrapper
#                 identifier. Built-in AnchorHub usage defaults this to '{'
#     * 'close:   a string corresponding ot the closing portion of the wrapper
#                 identifier. Built-in AnchorHub usage defaults this to '}'
#     * 'wrapper_regex':  An escaped regular expression that matches tags
#                         located inside of wrappers
# 
#     :param opts: namespace object, usually created from command-line
#         arguments, that is used to pass runtime options to concrete
#         WriterStrategy objects.
#     :return: A Writer object designed for parsing, modifying, and writing
#         AnchorHub tags to converted anchors in Markdown files using GitHub style
#         anchors
#     """
#     assert hasattr(opts, 'wrapper_regex')
#     atx = MarkdownATXWriterStrategy(opts, 'ATX headers')
#     setext = MarkdownSetextWriterStrategy(opts, 'Setext headers')
#     inline = MarkdownInlineLinkWriterStrategy(opts, 'inline links')
#     ref = MarkdownReferenceLinkWriterStrategy(opts, 'reference links')
#     code_block_switch = ghswitches.code_block_switch
# 
#     strategies = [atx, setext, inline, ref]
#     switches = [code_block_switch]
# 
#     return Writer(strategies, switches=switches)


import anchorhub.cmdparse as cmdparse
import anchorhub.fileparse as fileparse
import anchorhub.messages as messages
import anchorhub.normalization.normalize_opts as normalize_opts
import anchorhub.validation.validate_opts as validate_opts
import anchorhub.validation.validate_files as validate_files
import anchorhub.validation.validate_anchors as validate_anchors
from anchorhub.builtin.github.collector import make_github_markdown_collector
from anchorhub.builtin.github.writer import make_github_markdown_writer
    """
    Main entry method for AnchorHub. Takes in command-line arguments,
    finds files to parse within the specified input directory, and outputs
    parsed files to the specified output directory.

    :param argv: a list of string command line arguments
    """
    # Get command line arguments, validate them, and normalize them
    opts = cmdparse.parse_args(argv)
    assert validate_opts.validate(opts)
    opts = normalize_opts.normalize(opts)

    if opts.verbose:
        # Update client: print input and output directories
        messages.print_input_output(opts)

    file_paths = fileparse.get_file_list(opts)
    assert validate_files.validate(file_paths, opts)

    if opts.verbose and opts.is_dir:
        # Update client: print files that will be parsed
        messages.print_files(opts, file_paths)

    # For now, only using default GitHub Markdown for parsing
    # Collect tag/anchor combinations
    collector = make_github_markdown_collector(opts)
    anchors, duplicate_tags = collector.collect(file_paths)
    assert validate_anchors.validate(anchors, duplicate_tags, opts)

    # Write files using previously found AnchorHub tags and generated anchors

# Path: anchorhub/builtin/github/collector.py
# def make_github_markdown_collector(opts):
#     """
#     Creates a Collector object used for parsing Markdown files with a GitHub
#     style anchor transformation
# 
#     :param opts: Namespace object of options for the AnchorHub program.
#     Usually created from command-line arguments. It must contain a
#     'wrapper_regex' attribute
#     :return: a Collector object designed for collecting tag/anchor pairs from
#     Markdown files using GitHub style anchors
#     """
#     assert hasattr(opts, 'wrapper_regex')
#     atx = MarkdownATXCollectorStrategy(opts)
#     setext = MarkdownSetextCollectorStrategy(opts)
#     code_block_switch = ghswitches.code_block_switch
# 
#     strategies = [atx, setext]
#     switches = [code_block_switch]
# 
#     return Collector(converter.create_anchor_from_header, strategies,
#                      switches=switches)
# 
# Path: anchorhub/builtin/github/writer.py
# def make_github_markdown_writer(opts):
#     """
#     Creates a Writer object used for parsing and writing Markdown files with
#     a GitHub style anchor transformation
# 
#     opts is a namespace object containing runtime options. It should
#     generally include the following attributes:
# 
#     * 'open':   a string corresponding to the opening portion of the wrapper
#                 identifier. Built-in AnchorHub usage defaults this to '{'
#     * 'close:   a string corresponding ot the closing portion of the wrapper
#                 identifier. Built-in AnchorHub usage defaults this to '}'
#     * 'wrapper_regex':  An escaped regular expression that matches tags
#                         located inside of wrappers
# 
#     :param opts: namespace object, usually created from command-line
#         arguments, that is used to pass runtime options to concrete
#         WriterStrategy objects.
#     :return: A Writer object designed for parsing, modifying, and writing
#         AnchorHub tags to converted anchors in Markdown files using GitHub style
#         anchors
#     """
#     assert hasattr(opts, 'wrapper_regex')
#     atx = MarkdownATXWriterStrategy(opts, 'ATX headers')
#     setext = MarkdownSetextWriterStrategy(opts, 'Setext headers')
#     inline = MarkdownInlineLinkWriterStrategy(opts, 'inline links')
#     ref = MarkdownReferenceLinkWriterStrategy(opts, 'reference links')
#     code_block_switch = ghswitches.code_block_switch
# 
#     strategies = [atx, setext, inline, ref]
#     switches = [code_block_switch]
# 
#     return Writer(strategies, switches=switches)


# Path: anchorhub/main.py
import anchorhub.cmdparse as cmdparse
import anchorhub.fileparse as fileparse
import anchorhub.messages as messages
import anchorhub.normalization.normalize_opts as normalize_opts
import anchorhub.validation.validate_opts as validate_opts
import anchorhub.validation.validate_files as validate_files
import anchorhub.validation.validate_anchors as validate_anchors
from anchorhub.builtin.github.collector import make_github_markdown_collector
from anchorhub.builtin.github.writer import make_github_markdown_writer

    """
    Main entry method for AnchorHub. Takes in command-line arguments,
    finds files to parse within the specified input directory, and outputs
    parsed files to the specified output directory.

    :param argv: a list of string command line arguments
    """
    # Get command line arguments, validate them, and normalize them
    opts = cmdparse.parse_args(argv)
    assert validate_opts.validate(opts)
    opts = normalize_opts.normalize(opts)

    if opts.verbose:
        # Update client: print input and output directories
        messages.print_input_output(opts)

    file_paths = fileparse.get_file_list(opts)
    assert validate_files.validate(file_paths, opts)

    if opts.verbose and opts.is_dir:
        # Update client: print files that will be parsed
        messages.print_files(opts, file_paths)

    # For now, only using default GitHub Markdown for parsing
    # Collect tag/anchor combinations
    collector = make_github_markdown_collector(opts)
    anchors, duplicate_tags = collector.collect(file_paths)
    assert validate_anchors.validate(anchors, duplicate_tags, opts)

    # Write files using previously found AnchorHub tags and generated anchors

    writer = make_github_markdown_writer(opts)