Python tensorflow_docs.api_generator.public_api.local_definitions_filter() Examples

The following are 11 code examples of tensorflow_docs.api_generator.public_api.local_definitions_filter(). 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.public_api , 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 lattice with Apache License 2.0 5 votes vote down vote up
def local_definitions_filter(path, parent, children):
  """Filters local imports, except for the tfl.layers module."""
  if path == ('tfl', 'layers'):
    return children
  return public_api.local_definitions_filter(path, parent, children) 
Example #9
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 #10
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 #11
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)