Example #1
0
def _build_guide_index(guide_src_dir):
  """Return dict: symbol name -> _GuideRef from the files in `guide_src_dir`."""
  index_generator = _GenerateGuideIndex()
  if os.path.exists(guide_src_dir):
    for full_path, base_name in py_guide_parser.md_files_in_dir(guide_src_dir):
      index_generator.process(full_path, base_name)
  return index_generator.index
Example #2
0
def _build_guide_index(guide_src_dir):
  """Return dict: symbol name -> _GuideRef from the files in `guide_src_dir`."""
  index_generator = _GenerateGuideIndex()
  if os.path.exists(guide_src_dir):
    for full_path, base_name in py_guide_parser.md_files_in_dir(guide_src_dir):
      index_generator.process(full_path, base_name)
  return index_generator.index
Example #3
0
def _main(input_dir, output_dir):
    """Convert all the files in `input_dir` and write results to `output_dir`."""
    visitor = generate.extract()

    # Make output_dir.
    try:
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)
    except OSError as e:
        print('Creating output dir "%s" failed: %s' % (output_dir, e))
        raise

    # How to get from api_guides/python/ to api_docs/python/
    relative_path_to_root = '../../api_docs/python/'

    # Iterate through all the source files and process them.
    tag_updater = UpdateTags()
    for full_path, base_name in py_guide_parser.md_files_in_dir(input_dir):
        print('Processing %s...' % base_name)
        md_string = tag_updater.process(full_path)
        output = parser.replace_references(md_string, relative_path_to_root,
                                           visitor.duplicate_of)
        open(os.path.join(output_dir, base_name), 'w').write(output)
    print('Done.')
def _main(input_dir, output_dir):
  """Convert all the files in `input_dir` and write results to `output_dir`."""
  visitor = generate.extract()

  # Make output_dir.
  try:
    if not os.path.exists(output_dir):
      os.makedirs(output_dir)
  except OSError as e:
    print('Creating output dir "%s" failed: %s' % (output_dir, e))
    raise

  # How to get from api_guides/python/ to api_docs/python/
  relative_path_to_root = '../../api_docs/python/'

  # Iterate through all the source files and process them.
  tag_updater = UpdateTags()
  for full_path, base_name in py_guide_parser.md_files_in_dir(input_dir):
    print('Processing %s...' % base_name)
    md_string = tag_updater.process(full_path)
    output = parser.replace_references(
        md_string, relative_path_to_root, visitor.duplicate_of)
    open(os.path.join(output_dir, base_name), 'w').write(output)
  print('Done.')