Python tensorflow_docs.api_generator.generate_lib.DocGenerator() Examples

The following are 15 code examples of tensorflow_docs.api_generator.generate_lib.DocGenerator(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tensorflow_docs.api_generator.generate_lib , or try the search function .
Example #1
Source File: build_docs.py    From lattice with Apache License 2.0 6 votes vote down vote up
def main(_):
  private_map = {
      'tfl': ['python'],
      'tfl.aggregation_layer': ['Aggregation'],
      'tfl.categorical_calibration_layer': ['CategoricalCalibration'],
      'tfl.lattice_layer': ['Lattice'],
      'tfl.linear_layer': ['Linear'],
      'tfl.pwl_calibration_layer': ['PWLCalibration'],
      'tfl.parallel_combination_layer': ['ParallelCombination'],
      'tfl.rtl_layer': ['RTL'],
  }
  doc_generator = generate_lib.DocGenerator(
      root_title='TensorFlow Lattice 2.0',
      py_modules=[('tfl', tfl)],
      base_dir=os.path.dirname(tfl.__file__),
      code_url_prefix=FLAGS.code_url_prefix,
      search_hints=FLAGS.search_hints,
      site_path=FLAGS.site_path,
      private_map=private_map,
      callbacks=[local_definitions_filter])

  sys.exit(doc_generator.build(output_dir=FLAGS.output_dir)) 
Example #2
Source File: build_api_docs.py    From OpenFermion with Apache License 2.0 6 votes vote down vote up
def main(unused_argv):

    doc_generator = generate_lib.DocGenerator(
        root_title="OpenFermion",
        py_modules=[("openfermion", openfermion)],
        base_dir=os.path.dirname(openfermion.__file__),
        code_url_prefix=FLAGS.code_url_prefix,
        search_hints=FLAGS.search_hints,
        site_path=FLAGS.site_path,
        callbacks=[public_api.local_definitions_filter],
        private_map={
            # Module paths to skip when crawling source code.
            # Example:
            # "cirq.google.engine.client.quantum.QuantumEngineServiceClient":
            # ["enums"]
        })

    doc_generator.build(output_dir=FLAGS.output_dir) 
Example #3
Source File: build_docs.py    From addons with Apache License 2.0 6 votes vote down vote up
def main(argv):
    if argv[1:]:
        raise ValueError("Unrecognized arguments: {}".format(argv[1:]))

    if FLAGS.code_url_prefix:
        code_url_prefix = FLAGS.code_url_prefix
    elif FLAGS.git_branch:
        code_url_prefix = CODE_PREFIX_TEMPLATE.format(git_branch=FLAGS.git_branch)
    else:
        code_url_prefix = CODE_PREFIX_TEMPLATE.format(git_branch="master")

    doc_generator = generate_lib.DocGenerator(
        root_title=PROJECT_FULL_NAME,
        py_modules=[(PROJECT_SHORT_NAME, tfa)],
        code_url_prefix=code_url_prefix,
        private_map={"tfa": ["__version__", "utils", "version"]},
        # This callback usually cleans up a lot of aliases caused by internal imports.
        callbacks=[public_api.local_definitions_filter],
        search_hints=FLAGS.search_hints,
        site_path=FLAGS.site_path,
    )

    doc_generator.build(FLAGS.output_dir)

    print("Output docs to: ", FLAGS.output_dir) 
Example #4
Source File: build_docs.py    From neural-structured-learning with Apache License 2.0 6 votes vote down vote up
def main(_):
  do_not_generate_docs_for = []

  for blocked_doc in do_not_generate_docs_for:
    doc_controls.do_not_generate_docs(blocked_doc)

  doc_generator = generate_lib.DocGenerator(
      root_title="Neural Structured Learning",
      py_modules=[("nsl", nsl)],
      code_url_prefix=FLAGS.code_url_prefix,
      search_hints=FLAGS.search_hints,
      site_path=FLAGS.site_path,
      # local_definitions_filter ensures that shared modules are only
      # documented in the location that defines them, instead of every location
      # that imports them.
      callbacks=[public_api.local_definitions_filter])
  doc_generator.build(output_dir=FLAGS.output_dir) 
Example #5
Source File: build_api_docs.py    From Cirq with Apache License 2.0 6 votes vote down vote up
def main(unused_argv):

    doc_generator = generate_lib.DocGenerator(
        root_title="Cirq",
        py_modules=[("cirq", cirq)],
        base_dir=os.path.dirname(cirq.__file__),
        code_url_prefix=FLAGS.code_url_prefix,
        search_hints=FLAGS.search_hints,
        site_path=FLAGS.site_path,
        callbacks=[public_api.local_definitions_filter],
        private_map={
            # Opt to not build docs for these paths for now since they error.
            "cirq.google.engine.client.quantum.QuantumEngineServiceClient":
            ["enums"],
            "cirq.google.engine.client.quantum_v1alpha1.QuantumEngineServiceClient":
            ["enums"]
        })

    doc_generator.build(output_dir=FLAGS.output_dir) 
Example #6
Source File: build_docs.py    From model-analysis with Apache License 2.0 6 votes vote down vote up
def main(args):
  if args[1:]:
    raise ValueError('Unrecognized command line args', args[1:])

  for obj in suppress_docs_for:
    doc_controls.do_not_generate_docs(obj)

  doc_generator = generate_lib.DocGenerator(
      root_title='TensorFlow Model Analysis',
      py_modules=[('tfma', tfma)],
      base_dir=os.path.dirname(tfma.__file__),
      code_url_prefix=FLAGS.code_url_prefix,
      search_hints=FLAGS.search_hints,
      site_path=FLAGS.site_path,
      private_map={},
      callbacks=[
          public_api.local_definitions_filter, depth_filter, suppress_docs
      ])

  return doc_generator.build(output_dir=FLAGS.output_dir) 
Example #7
Source File: build_docs.py    From hub with Apache License 2.0 6 votes vote down vote up
def main(args):
  if args[1:]:
    raise ValueError('Unrecognized command line args', args[1:])

  for obj in suppress_docs_for:
    doc_controls.do_not_generate_docs(obj)

  doc_generator = generate_lib.DocGenerator(
      root_title='TensorFlow Hub',
      py_modules=[('hub', hub)],
      base_dir=os.path.dirname(hub.__file__),
      code_url_prefix=FLAGS.code_url_prefix,
      search_hints=FLAGS.search_hints,
      site_path=FLAGS.site_path,
      private_map={},
      callbacks=[
          # This filters out objects not defined in the current module or its
          # sub-modules.
          public_api.local_definitions_filter
      ])

  doc_generator.build(output_dir=FLAGS.output_dir) 
Example #8
Source File: build_docs.py    From data-validation with Apache License 2.0 5 votes vote down vote up
def main(args):
  if args[1:]:
    raise ValueError("Unrecognized Command line args", args[1:])

  for obj in supress_docs_for:
    doc_controls.do_not_generate_docs(obj)

  for name, value in inspect.getmembers(tfdv):
    if inspect.ismodule(value):
      doc_controls.do_not_generate_docs(value)

  for name, value in inspect.getmembers(beam.PTransform):
    # This ensures that the methods of PTransform are not documented in any
    # derived classes.
    if name == "__init__":
      continue
    try:
      doc_controls.do_not_doc_inheritable(value)
    except (TypeError, AttributeError):
      pass

  doc_generator = generate_lib.DocGenerator(
      root_title="TensorFlow Data Validation",
      py_modules=[("tfdv", tfdv)],
      code_url_prefix=FLAGS.code_url_prefix,
      search_hints=FLAGS.search_hints,
      site_path=FLAGS.site_path,
      # Use private_map to exclude doc locations by name if excluding by object
      # is insufficient.
      private_map={},
      # local_definitions_filter ensures that shared modules are only
      # documented in the location that defines them, instead of every location
      # that imports them.
      callbacks=[public_api.local_definitions_filter, _filter_class_attributes])

  return doc_generator.build(output_dir=FLAGS.output_dir) 
Example #9
Source File: build_docs.py    From graphics with Apache License 2.0 5 votes vote down vote up
def main(_):
  doc_generator = generate_lib.DocGenerator(
      root_title="Tensorflow Graphics",
      py_modules=[("tfg", tfg)],
      base_dir=os.path.dirname(tfg.__file__),
      search_hints=FLAGS.search_hints,
      code_url_prefix=FLAGS.code_url_prefix,
      site_path=FLAGS.site_path)

  doc_generator.build(output_dir=FLAGS.output_dir) 
Example #10
Source File: build_api_docs.py    From datasets with Apache License 2.0 5 votes vote down vote up
def execute(output_dir, code_url_prefix, search_hints, site_path):
  """Builds API docs for tensorflow_datasets."""
  # Internally, tfds.testing defaults to None. Fill it in here so that we get
  # documentation.
  tfds.testing = testing
  doc_generator = generate_lib.DocGenerator(
      root_title="TensorFlow Datasets",
      py_modules=[("tfds", tfds)],
      base_dir=os.path.dirname(tfds.__file__),
      search_hints=search_hints,
      code_url_prefix=code_url_prefix,
      site_path=site_path)

  doc_generator.build(output_dir)

  new_redirects = []
  for before, after in MOVES:
    old_path = os.path.join(output_dir, before)
    new_path = os.path.join(output_dir, after)
    os.rename(old_path, new_path)

    new_redirects.append({
        "from":
            os.path.join("/datasets/api_docs/python/",
                         os.path.splitext(before)[0]),
        "to":
            os.path.join("/datasets/api_docs/python/",
                         os.path.splitext(after)[0])
    })

  redirect_path = os.path.join(output_dir, "_redirects.yaml")
  with open(redirect_path) as f:
    redirect_content = yaml.load(f)
  redirect_content["redirects"].extend(new_redirects)
  with open(redirect_path, "w") as f:
    yaml.dump(redirect_content, f, default_flow_style=False) 
Example #11
Source File: build_docs.py    From tfx with Apache License 2.0 5 votes vote down vote up
def main(_):
  # These make up for the empty __init__.py files.
  api_generator.utils.recursive_import(tfx.orchestration)
  api_generator.utils.recursive_import(tfx.components)

  do_not_generate_docs_for = []
  for name in ["utils", "proto", "dependencies", "version"]:
    submodule = getattr(tfx, name, None)
    if submodule is not None:
      do_not_generate_docs_for.append(submodule)

  for obj in do_not_generate_docs_for:
    doc_controls.do_not_generate_docs(obj)

  doc_generator = generate_lib.DocGenerator(
      root_title="TFX",
      py_modules=[("tfx", tfx)],
      code_url_prefix=FLAGS.code_url_prefix,
      search_hints=FLAGS.search_hints,
      site_path=FLAGS.site_path,
      private_map={},
      # local_definitions_filter ensures that shared modules are only
      # documented in the location that defines them, instead of every location
      # that imports them.
      callbacks=[
          api_generator.public_api.local_definitions_filter, ignore_test_objects
      ])
  doc_generator.build(output_dir=FLAGS.output_dir) 
Example #12
Source File: build_docs.py    From agents with Apache License 2.0 5 votes vote down vote up
def main(_):
  doc_generator = generate_lib.DocGenerator(
      root_title='TF-Agents',
      py_modules=[('tf_agents', tf_agents)],
      base_dir=os.path.dirname(tf_agents.__file__),
      code_url_prefix=FLAGS.code_url_prefix,
      search_hints=FLAGS.search_hints,
      site_path=FLAGS.site_path,
      private_map={},
      callbacks=[public_api.local_definitions_filter])

  sys.exit(doc_generator.build(output_dir=FLAGS.output_dir)) 
Example #13
Source File: generate_docs.py    From compression with Apache License 2.0 5 votes vote down vote up
def main(_):
  doc_generator = generate_lib.DocGenerator(
      root_title="TensorFlow/compression",
      py_modules=[("tfc", tfc)],
      base_dir=os.path.dirname(tfc.__file__),
      private_map={
          "tfc.python.ops": ["gen_range_coding_ops", "namespace_helper"],
      },
      code_url_prefix="https://github.com/tensorflow/compression/tree/master/"
                      "tensorflow_compression",
      api_cache=False,
  )
  sys.exit(doc_generator.build(FLAGS.output_dir)) 
Example #14
Source File: build_docs.py    From model-optimization with Apache License 2.0 4 votes vote down vote up
def main(unused_argv):
  doc_generator = generate_lib.DocGenerator(
      root_title="TensorFlow Model Optimization",
      py_modules=[("tfmot", tfmot)],
      base_dir=os.path.dirname(tfmot.__file__),
      code_url_prefix=FLAGS.code_url_prefix,
      search_hints=FLAGS.search_hints,
      site_path=FLAGS.site_path,
      # TODO(tfmot): remove this once the next release after 0.3.0 happens.
      # This is needed in the interim because the API docs reflect
      # the latest release and the current release still wildcard imports
      # all of the classes below.
      private_map={
          "tfmot.sparsity.keras": [
              # List of internal classes which get exposed when imported.
              "InputLayer",
              "custom_object_scope",
              "pruning_sched",
              "pruning_wrapper",
              "absolute_import",
              "division",
              "print_function",
              "compat"
          ]
      },
  )

  doc_generator.build(output_dir=FLAGS.output_dir) 
Example #15
Source File: build_docs.py    From transform with Apache License 2.0 4 votes vote down vote up
def main(args):
  if args[1:]:
    raise ValueError('Unrecognized Command line args', args[1:])

  tft_out = pathlib.Path(tempfile.mkdtemp())
  doc_generator = generate_lib.DocGenerator(
      root_title='TF-Transform',
      py_modules=[('tft', transform)],
      code_url_prefix=FLAGS.code_url_prefix,
      search_hints=FLAGS.search_hints,
      site_path=FLAGS.site_path,
      callbacks=[public_api.explicit_package_contents_filter])

  doc_generator.build(tft_out)

  doc_controls.do_not_generate_docs(tft_beam.analyzer_impls)

  tft_beam_out = pathlib.Path(tempfile.mkdtemp())
  doc_generator = generate_lib.DocGenerator(
      root_title='TFT-Beam',
      py_modules=[('tft_beam', tft_beam)],
      code_url_prefix=FLAGS.code_url_prefix + '/beam',
      search_hints=FLAGS.search_hints,
      site_path=FLAGS.site_path,
      callbacks=[
          public_api.explicit_package_contents_filter,
          public_api.local_definitions_filter
      ])

  doc_generator.build(tft_beam_out)

  output_dir = pathlib.Path(FLAGS.output_dir)

  def splice(name, tmp_dir):
    shutil.rmtree(output_dir / name, ignore_errors=True)
    shutil.copytree(tmp_dir / name, output_dir / name)
    shutil.copy(tmp_dir / f'{name}.md', output_dir / f'{name}.md')
    try:
      shutil.copy(tmp_dir / '_redirects.yaml',
                  output_dir / name / '_redirects.yaml')
    except FileNotFoundError:
      pass
    shutil.copy(tmp_dir / '_toc.yaml', output_dir / name / '_toc.yaml')

  splice('tft', tft_out)
  splice('tft_beam', tft_beam_out)

  toc_path = output_dir / '_toc.yaml'
  toc_text = yaml.dump(
      {'toc': [
          {'include': f'{FLAGS.site_path}/tft/_toc.yaml'},
          {'break': True},
          {'include': f'{FLAGS.site_path}/tft_beam/_toc.yaml'}]})
  toc_path.write_text(toc_text)