New implementation of `./pants targets`.

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

Information
Benjy Weinberger
pants
Reviewers
pants-reviews
jsirois, lahosken, stuhood

The old one used the reflect.py 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 R.java.
      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.

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: https://travis-ci.org/pantsbuild/pants/builds/95112497

Manual testing.

Benjy Weinberger
Larry Hosken
Benjy Weinberger
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted as fbbf99b14e7dde11be6b5fc2786800a17007cd4d.

Benjy Weinberger

Thanks Larry. Submitted as fbbf99b14e7dde11be6b5fc2786800a17007cd4d.

Loading...