Giter VIP home page Giter VIP logo

apidiff's Introduction

API diff

Build Status codecov

An API diff tool for Objective-C, Swift, and Android code that outputs markdown.

Requirements

Objective-C and Swift engines both require:

Usage

Run apidiff from within a git repository like so:

apidiff <old git ref> <new git ref> objc <umbrella header>
apidiff <old git ref> <new git ref> swift <workspace path> <scheme name>
apidiff <old git ref> <new git ref> android <library>

Note that all paths must be relative to the root of the git repository. For example:

apidiff v1.0.0 v2.0.0 objc src/MaterialMotionRuntime.h

Example output

Auto-generated by running:

apidiff 734d43e406f53143c2cf8440f43d858d125f0a11 6f7a52744751e511d0daf119642446c46bed1f5c objc src/MaterialMotionRuntime.h

NewClass

new class: NewClass

new constructor: NewClass()

new field: text

new method: getText()

MDMPlanPerforming

removed method: -addPlan: in MDMPlanPerforming

modified protocol: MDMPlanPerforming

Type swift declaration
From protocol MDMPlanPerforming : MDMPerforming
To protocol PlanPerforming : Performing

MDMScheduler

modified property: delegate in MDMScheduler

Type swift declaration
From weak var delegate: MDMSchedulerDelegate? { get set }
To weak var delegate: SchedulerDelegate? { get set }

modified class: MDMScheduler

Type swift declaration
From class MDMScheduler : NSObject
To class Scheduler : NSObject

License

Licensed under the Apache 2.0 license. See LICENSE for details.

apidiff's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apidiff's Issues

Handle class renames

For sure, this is a problem on android. Not sure about apple.

See example output:

## ContinuousPerformance

*removed* interface: `ContinuousPerformance`

*removed* method: `void setIsActiveTokenGenerator(IsActiveTokenGenerator)`

## ContinuousPerforming

*new* interface: `ContinuousPerforming`

*new* method: `void setIsActiveTokenGenerator(IsActiveTokenGenerator)`

apidiff has no way of knowing that ContinuousPerformance was renamed to ContinuousPerforming. The only context it has is that ContinuousPerformance was removed and ContinuousPerforming was added. Ideally, the output should show that ContinuousPerformance was modified to ContinuousPerforming.

One possibility is to allow the user to specify renames on the command line.

API groupings should be alphabetized

Consider the following recent output:

## MDMSchedulerActivityStateIdle
## MDMSchedulerActivityState
## MDMSchedulerDelegate
## MDMConsoleLoggingTracer
## MDMRuntimeFeatures
## MDMPerforming
## MDMComposablePerforming
## MDMTransaction
## MDMScheduler
## MDMTransactionEmitting
## MDMTracing
## MDMRuntimeActivityState
## MDMRuntimeDelegate
## MDMSchedulerActivityStateActive
## MDMRuntime

These groups should be alphabetized.

[java] Parse KLASS generic type

For example:

public class foo.bar.Foo<T extends baz.qux.Bar>

Where signature should be foo.bar.Foo, but existing (\S+) captures foo.bar.Foo<T

strange component changes

MDC release 84.0.0 produced a weird snippet and was called out in this comment thread.

I suspect it is because the commit was not amended properly to use the PR's description. This is not something the API diff too can fix. Unless we want it to ignore the Commit message and use the resolved PR description?

[java] Parse METHOD generic type

For example:

public static <T> void bind(T);

Should have:
signature: <T> bind(T)
short_description: <T> void bind(T)

And:

public static <T extends Bar> void bind(T);

Should have:
signature: <T extends Bar> bind(T)
short_description: <T extends Bar> void bind(T)

Right now, short_description is parsed correctly, but only because object_type = '.+?\s+' matches <T> void, which is actually a bug. object_type should match void instead.

Right now, signature is not parsed correctly. It is parsed as bind(T) when it needs to have the typed parameter as well to distinguish from the two cases above which are both legal in the same class.

Add support for highlighting breaking API changes

From alexisgallagher:

Does it auto generate an indication when the API change breaks compatibility for code that depended on the old API?

Things we need to do to make this happen:

  • Add a new API to ApiChange for isBreaking().
  • If an ApiChange is a breaking change, output additional markdown highlighting this fact.

It may make sense to aggregate breaking API changes near the top of the output as well.

[java] Support java libraries

Right now this tool looks for an android library AAR output at $library/build/outputs/aar/$library-debug.aar. Java libraries output a JAR file at $library/build/libs/$library.jar. If we look there as well, this tool would work as-is for Java libraries.

Can't get API diff to work on my machine

When running scripts/release apidiff while doing a Material-Components-iOS release the output is

Changelog=/var/folders/5g/3j6wbymd03jbv54v218wgbvw00jg1r/T/tmp.E0SqXEWc/changelog
Errors=/var/folders/5g/3j6wbymd03jbv54v218wgbvw00jg1r/T/tmp.E0SqXEWc/errlog
Diffing Chips (components/Chips/src)...

But nothing happens.

This is with sourcekitten 0.23.2.

Support including and filtering by framework dependencies

Objective-C frameworks that have dependencies don't work with apidiff due to the inability to resolve header imports. If these imports are resolved, apidiff ends up generating API diffs for both the current library and all of its dependencies (certainly not ideal).

Ideally apidiff would check out the relevant dependencies at the relevant versions and then filter apidiff results to only those found within the current library.

Add support for JSON output

This would simplify integration with other tooling.

I 'm thinking of a --json flag that would change the output from formatted markdown to JSON.

[objc] Category line movement generates non-sensical API diff

Strange changes when category implementations are shifted down in a file.

Repro case

Before

@interface MDCFlexibleHeaderView: UIView
@property(nonatomic, strong) UIView *someView;
@end

@interface MDCFlexibleHeaderView ()

#pragma mark Accessing the header's views

/** Deprecated. Please register views directly to the flexible header. */
@property(nonatomic, strong, nonnull) UIView *contentView;

@end

After

@interface MDCFlexibleHeaderView: UIView
@property(nonatomic, strong) UIView *someView;
@property(nonatomic, strong) UIView *anotherView;
@end

@interface MDCFlexibleHeaderView ()

#pragma mark Accessing the header's views

/** Deprecated. Please register views directly to the flexible header. */
@property(nonatomic, strong, nonnull) UIView *contentView;

@end

Partial generated output

None of the following is expected to be generated:

#### MDCFlexibleHeaderView()

 *new* category: `MDCFlexibleHeaderView()`

 *removed* category: `MDCFlexibleHeaderView()`

 *modified* property: `contentView` in `MDCFlexibleHeaderView()`

 | Type of change: | parent.usr |
|---|---|
| From: | `c:objc(ext)[email protected]@14009` |
| To: | `c:objc(ext)[email protected]@14344` |

Support for running on Travis CI

Ideal outcome of this task is apidiff generating an API diff artifact on each commit to develop for a repo, such that when a release is cut we can simply grab the latest apidiff artifact from Travis.

Some other cool features this would enable:

  • CI notifications for when the public API changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.