New implementation of `./pants targets`.

Review Request #3214 — Created Dec. 5, 2015 and submitted

jsirois, lahosken, stuhood

The old one used the module, which I'm trying to get rid of as
it's become brittle.

Also took the opportunity to fix up the docstrings on Target subclasses so
that the ./pants targets output is more succinct and useful.

New output with no arguments is similar to the old one, but with colors:

            android_binary: An Android binary.
        android_dependency: Artifacts that Android targets depend on.
           android_library: Android library projects that access Android API or Android resources.
         android_resources: Android resources used to generate
      annotation_processor: A Java library containing annotation processors.
                 benchmark: A caliper benchmark.
            contrib_plugin: A contributed pants plugin published by pantsbuild.

But note that the old task emitted an undifferentiated mix of target types and other BUILD file symbols like scm or globs. The new task only shows targets, as befits its name. In the future we can add a section with output for those other symbols if deemed necessary.

New output with the --details argument is better formatted:

./pants targets --details=java_library
A Java library.

name = ...,
dependencies = ..., (default: [])
description = ..., (default: None)
tags = ..., (default: None)
no_cache = ..., (default: False)
sources = ..., Source code files to build. Paths are relative to the BUILD (default: None)
provides = ..., (default: None)
excludes = ..., List of exclude <#exclude>_\s to filter this target's (default: None)
resources = ..., (default: None)
services = ..., A dict mapping service interface names to the classes owned by this target (default: None)
platform = ..., The name of the platform (defined under the jvm-platform subsystem) to use (default: None)
strict_deps = ..., When True, only the directly declared deps of the target will be used at (default: None)
fatal_warnings = ..., Whether to turn warnings into errors for this target. If present, (default: None)

Note that this takes the description from the first line of the :param: doc for the argument, if any. So at some point we should audit our target type docstrings.

CI passes:

Manual testing.

  1. Nudge...

  1. Yay, thank you for doing this
  2. add a docstring? I had to look around to figure out what this gave me.
    1. Good call, done.

Review request changed

Status: Closed (submitted)

Change Summary:

Submitted as fbbf99b14e7dde11be6b5fc2786800a17007cd4d.

  1. Thanks Larry. Submitted as fbbf99b14e7dde11be6b5fc2786800a17007cd4d.