parameters: (output_dir, parser_config, yaml_toc, root_title='TensorFlow')
docstring: Write previously extracted docs to disk.
  
    Write a docs page for each symbol included in the indices of parser_config to
    a tree of docs at `output_dir`.
  
    Symbols with multiple aliases will have only one page written about
    them, which is referenced for all aliases.
  
    Args:
      output_dir: Directory to write documentation markdown files to. Will be
        created if it doesn't exist.
      parser_config: A `parser.ParserConfig` object, containing all the necessary
        indices.
      yaml_toc: Set to `True` to generate a "_toc.yaml" file.
      root_title: The title name for the root level index.md.
  
    Raises:
      ValueError: if `output_dir` is not an absolute path
docstring_summary: Write previously extracted docs to disk.
docstring_tokens: Write previously extracted docs to disk .
function: def write_docs(output_dir, parser_config, yaml_toc, root_title='TensorFlow'):
    """Write previously extracted docs to disk.
  
    Write a docs page for each symbol included in the indices of parser_config to
    a tree of docs at `output_dir`.
  
    Symbols with multiple aliases will have only one page written about
    them, which is referenced for all aliases.
  
    Args:
      output_dir: Directory to write documentation markdown files to. Will be
        created if it doesn't exist.
      parser_config: A `parser.ParserConfig` object, containing all the necessary
        indices.
      yaml_toc: Set to `True` to generate a "_toc.yaml" file.
      root_title: The title name for the root level index.md.
  
    Raises:
      ValueError: if `output_dir` is not an absolute path
    """
    # Make output_dir.
    if not os.path.isabs(output_dir):
      raise ValueError("'output_dir' must be an absolute path.\n"
                       "    output_dir='%s'" % 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
  
    # These dictionaries are used for table-of-contents generation below
    # They will contain, after the for-loop below::
    #  - module name(string):classes and functions the module contains(list)
    module_children = {}
    #  - symbol name(string):pathname (string)
    symbol_to_file = {}
  
    # Parse and write Markdown pages, resolving cross-links (@{symbol}).
    for full_name, py_object in six.iteritems(parser_config.index):
      parser_config.reference_resolver.current_doc_full_name = full_name
  
      if full_name in parser_config.duplicate_of:
        continue
  
      # Methods and some routines are documented only as part of their class.
      if not (tf_inspect.ismodule(py_object) or tf_inspect.isclass(py_object) or
              _is_free_function(py_object, full_name, parser_config.index)):
        continue
  
      sitepath = os.path.join('api_docs/python',
                              parser.documentation_path(full_name)[:-3])
  
      # For TOC, we need to store a mapping from full_name to the file
      # we're generating
      symbol_to_file[full_name] = sitepath
  
      # For a module, remember the module for the table-of-contents
      if tf_inspect.ismodule(py_object):
        if full_name in parser_config.tree:
          module_children.setdefault(full_name, [])
  
      # For something else that's documented,
      # figure out what module it lives in
      else:
        subname = str(full_name)
        while True:
          subname = subname[:subname.rindex('.')]
          if tf_inspect.ismodule(parser_config.index[subname]):
            module_children.setdefault(subname, []).append(full_name)
            break
  
      print('Writing docs for %s (%r).' % (full_name, py_object))
  
      # Generate docs for `py_object`, resolving references.
      page_info = parser.docs_for_object(full_name, py_object, parser_config)
  
      path = os.path.join(output_dir, parser.documentation_path(full_name))
      directory = os.path.dirname(path)
      try:
        if not os.path.exists(directory):
          os.makedirs(directory)
        with open(path, 'w') as f:
          f.write(pretty_docs.build_md_page(page_info))
      except OSError as e:
        print('Cannot write documentation for %s to %s: %s' % (full_name,
                                                               directory, e))
        raise
  
    if yaml_toc:
      # Generate table of contents
  
      # Put modules in alphabetical order, case-insensitive
      modules = sorted(module_children.keys(), key=lambda a: a.upper())
  
      leftnav_path = os.path.join(output_dir, '_toc.yaml')
      with open(leftnav_path, 'w') as f:
  
        # Generate header
        f.write('# Automatically generated file; please do not edit\ntoc:\n')
        for module in modules:
          f.write('  - title: ' + module + '\n'
                  '    section:\n' + '    - title: Overview\n' +
                  '      path: /TARGET_DOC_ROOT/VERSION/' + symbol_to_file[module]
                  + '\n')
  
          symbols_in_module = module_children.get(module, [])
          # Sort case-insensitive, if equal sort case sensitive (upper first)
          symbols_in_module.sort(key=lambda a: (a.upper(), a))
  
          for full_name in symbols_in_module:
            f.write('    - title: ' + full_name[len(module) + 1:] + '\n'
                    '      path: /TARGET_DOC_ROOT/VERSION/' +
                    symbol_to_file[full_name] + '\n')
  
    # Write a global index containing all full names with links.
    with open(os.path.join(output_dir, 'index.md'), 'w') as f:
      f.write(
          parser.generate_global_index(root_title, parser_config.index,
                                       parser_config.reference_resolver))
function_tokens: def write_docs ( output_dir , parser_config , yaml_toc , root_title = 'TensorFlow' ) : # Make output_dir. if not os . path . isabs ( output_dir ) : raise ValueError ( "'output_dir' must be an absolute path.\n" "    output_dir='%s'" % 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 # These dictionaries are used for table-of-contents generation below # They will contain, after the for-loop below:: #  - module name(string):classes and functions the module contains(list) module_children = { } #  - symbol name(string):pathname (string) symbol_to_file = { } # Parse and write Markdown pages, resolving cross-links (@{symbol}). for full_name , py_object in six . iteritems ( parser_config . index ) : parser_config . reference_resolver . current_doc_full_name = full_name if full_name in parser_config . duplicate_of : continue # Methods and some routines are documented only as part of their class. if not ( tf_inspect . ismodule ( py_object ) or tf_inspect . isclass ( py_object ) or _is_free_function ( py_object , full_name , parser_config . index ) ) : continue sitepath = os . path . join ( 'api_docs/python' , parser . documentation_path ( full_name ) [ : - 3 ] ) # For TOC, we need to store a mapping from full_name to the file # we're generating symbol_to_file [ full_name ] = sitepath # For a module, remember the module for the table-of-contents if tf_inspect . ismodule ( py_object ) : if full_name in parser_config . tree : module_children . setdefault ( full_name , [ ] ) # For something else that's documented, # figure out what module it lives in else : subname = str ( full_name ) while True : subname = subname [ : subname . rindex ( '.' ) ] if tf_inspect . ismodule ( parser_config . index [ subname ] ) : module_children . setdefault ( subname , [ ] ) . append ( full_name ) break print ( 'Writing docs for %s (%r).' % ( full_name , py_object ) ) # Generate docs for `py_object`, resolving references. page_info = parser . docs_for_object ( full_name , py_object , parser_config ) path = os . path . join ( output_dir , parser . documentation_path ( full_name ) ) directory = os . path . dirname ( path ) try : if not os . path . exists ( directory ) : os . makedirs ( directory ) with open ( path , 'w' ) as f : f . write ( pretty_docs . build_md_page ( page_info ) ) except OSError as e : print ( 'Cannot write documentation for %s to %s: %s' % ( full_name , directory , e ) ) raise if yaml_toc : # Generate table of contents # Put modules in alphabetical order, case-insensitive modules = sorted ( module_children . keys ( ) , key = lambda a : a . upper ( ) ) leftnav_path = os . path . join ( output_dir , '_toc.yaml' ) with open ( leftnav_path , 'w' ) as f : # Generate header f . write ( '# Automatically generated file; please do not edit\ntoc:\n' ) for module in modules : f . write ( '  - title: ' + module + '\n' '    section:\n' + '    - title: Overview\n' + '      path: /TARGET_DOC_ROOT/VERSION/' + symbol_to_file [ module ] + '\n' ) symbols_in_module = module_children . get ( module , [ ] ) # Sort case-insensitive, if equal sort case sensitive (upper first) symbols_in_module . sort ( key = lambda a : ( a . upper ( ) , a ) ) for full_name in symbols_in_module : f . write ( '    - title: ' + full_name [ len ( module ) + 1 : ] + '\n' '      path: /TARGET_DOC_ROOT/VERSION/' + symbol_to_file [ full_name ] + '\n' ) # Write a global index containing all full names with links. with open ( os . path . join ( output_dir , 'index.md' ) , 'w' ) as f : f . write ( parser . generate_global_index ( root_title , parser_config . index , parser_config . reference_resolver ) )