Commit 63b70443 authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Don't generate @see links for private externs

See https://bugs.chromium.org/p/chromium/issues/detail?id=613096#c5 for
rationale

These two files:
third_party/closure_compiler/externs/accessibility_private.js
third_party/closure_compiler/externs/autofill_private.js
were updated in this commit, as an example of the change.

A follow-up commit will update other *_private.js files.

Bug: 613096
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Ica4ab471956052b37c8bb6a9aabe4a7502408cfb
Reviewed-on: https://chromium-review.googlesource.com/1090425
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568702}
parent 9fa1f15d
......@@ -21,7 +21,6 @@ chrome.accessibilityPrivate = {};
* @typedef {{
* message: string
* }}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#type-AlertInfo
*/
chrome.accessibilityPrivate.AlertInfo;
......@@ -33,13 +32,11 @@ chrome.accessibilityPrivate.AlertInfo;
* width: number,
* height: number
* }}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#type-ScreenRect
*/
chrome.accessibilityPrivate.ScreenRect;
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#type-Gesture
*/
chrome.accessibilityPrivate.Gesture = {
CLICK: 'click',
......@@ -63,7 +60,6 @@ chrome.accessibilityPrivate.Gesture = {
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#type-SyntheticKeyboardEventType
*/
chrome.accessibilityPrivate.SyntheticKeyboardEventType = {
KEYUP: 'keyup',
......@@ -77,7 +73,6 @@ chrome.accessibilityPrivate.SyntheticKeyboardEventType = {
* search: (boolean|undefined),
* shift: (boolean|undefined)
* }}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#type-SyntheticKeyboardModifiers
*/
chrome.accessibilityPrivate.SyntheticKeyboardModifiers;
......@@ -87,13 +82,11 @@ chrome.accessibilityPrivate.SyntheticKeyboardModifiers;
* keyCode: number,
* modifiers: (!chrome.accessibilityPrivate.SyntheticKeyboardModifiers|undefined)
* }}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#type-SyntheticKeyboardEvent
*/
chrome.accessibilityPrivate.SyntheticKeyboardEvent;
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#type-KeyboardMode
*/
chrome.accessibilityPrivate.KeyboardMode = {
FULL_WIDTH: 'FULL_WIDTH',
......@@ -102,7 +95,6 @@ chrome.accessibilityPrivate.KeyboardMode = {
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#type-SelectToSpeakState
*/
chrome.accessibilityPrivate.SelectToSpeakState = {
SELECTING: 'selecting',
......@@ -115,7 +107,6 @@ chrome.accessibilityPrivate.SelectToSpeakState = {
* the calling extension to provide accessibility for web contents.
* @param {boolean} enabled True if native accessibility support should be
* enabled.
* @see https://developer.chrome.com/extensions/accessibilityPrivate#method-setNativeAccessibilityEnabled
*/
chrome.accessibilityPrivate.setNativeAccessibilityEnabled = function(enabled) {};
......@@ -125,7 +116,6 @@ chrome.accessibilityPrivate.setNativeAccessibilityEnabled = function(enabled) {}
* rectangles to draw the accessibility focus ring around.
* @param {string=} color CSS-style hex color string beginning with # like
* #FF9982 or #EEE.
* @see https://developer.chrome.com/extensions/accessibilityPrivate#method-setFocusRing
*/
chrome.accessibilityPrivate.setFocusRing = function(rects, color) {};
......@@ -135,7 +125,6 @@ chrome.accessibilityPrivate.setFocusRing = function(rects, color) {};
* rectangles to draw the highlight around.
* @param {string} color CSS-style hex color string beginning with # like
* #FF9982 or #EEE.
* @see https://developer.chrome.com/extensions/accessibilityPrivate#method-setHighlights
*/
chrome.accessibilityPrivate.setHighlights = function(rects, color) {};
......@@ -149,14 +138,12 @@ chrome.accessibilityPrivate.setHighlights = function(rects, color) {};
* @param {boolean} capture True if key events should be swallowed natively and
* not propagated if preventDefault() gets called by the extension's
* background page.
* @see https://developer.chrome.com/extensions/accessibilityPrivate#method-setKeyboardListener
*/
chrome.accessibilityPrivate.setKeyboardListener = function(enabled, capture) {};
/**
* Darkens or undarkens the screen.
* @param {boolean} enabled True to darken screen; false to undarken screen.
* @see https://developer.chrome.com/extensions/accessibilityPrivate#method-darkenScreen
*/
chrome.accessibilityPrivate.darkenScreen = function(enabled) {};
......@@ -164,14 +151,12 @@ chrome.accessibilityPrivate.darkenScreen = function(enabled) {};
* Change the keyboard keys captured by Switch Access.
* @param {!Array<number>} key_codes The key codes for the keys that will be
* captured.
* @see https://developer.chrome.com/extensions/accessibilityPrivate#method-setSwitchAccessKeys
*/
chrome.accessibilityPrivate.setSwitchAccessKeys = function(key_codes) {};
/**
* Sets current ARC app to use native ARC support.
* @param {boolean} enabled True for ChromeVox (native), false for TalkBack.
* @see https://developer.chrome.com/extensions/accessibilityPrivate#method-setNativeChromeVoxArcSupportForCurrentApp
*/
chrome.accessibilityPrivate.setNativeChromeVoxArcSupportForCurrentApp = function(enabled) {};
......@@ -179,14 +164,12 @@ chrome.accessibilityPrivate.setNativeChromeVoxArcSupportForCurrentApp = function
* Sends a fabricated key event.
* @param {!chrome.accessibilityPrivate.SyntheticKeyboardEvent} keyEvent The
* event to send.
* @see https://developer.chrome.com/extensions/accessibilityPrivate#method-sendSyntheticKeyEvent
*/
chrome.accessibilityPrivate.sendSyntheticKeyEvent = function(keyEvent) {};
/**
* Fired whenever ChromeVox should output introduction.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#event-onIntroduceChromeVox
*/
chrome.accessibilityPrivate.onIntroduceChromeVox;
......@@ -194,7 +177,6 @@ chrome.accessibilityPrivate.onIntroduceChromeVox;
* Fired when an accessibility gesture is detected by the touch exploration
* controller.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#event-onAccessibilityGesture
*/
chrome.accessibilityPrivate.onAccessibilityGesture;
......@@ -202,7 +184,6 @@ chrome.accessibilityPrivate.onAccessibilityGesture;
* Fired when we first detect two fingers are held down, which can be used to
* toggle spoken feedback on some touch-only devices.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#event-onTwoFingerTouchStart
*/
chrome.accessibilityPrivate.onTwoFingerTouchStart;
......@@ -210,7 +191,6 @@ chrome.accessibilityPrivate.onTwoFingerTouchStart;
* Fired when the user is no longer holding down two fingers (including
* releasing one, holding down three, or moving them).
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#event-onTwoFingerTouchStop
*/
chrome.accessibilityPrivate.onTwoFingerTouchStop;
......@@ -219,7 +199,6 @@ chrome.accessibilityPrivate.onTwoFingerTouchStop;
* between selecting with the mouse, speaking, and inactive.
* @param {!chrome.accessibilityPrivate.SelectToSpeakState} state The current
* state of the Select-to-Speak extension
* @see https://developer.chrome.com/extensions/accessibilityPrivate#method-onSelectToSpeakStateChanged
*/
chrome.accessibilityPrivate.onSelectToSpeakStateChanged = function(state) {};
......@@ -227,6 +206,5 @@ chrome.accessibilityPrivate.onSelectToSpeakStateChanged = function(state) {};
* Called when Chrome OS wants to toggle the Select-to-Speak state, between selecting
* with the mouse, speaking, and inactive
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/accessibilityPrivate#event-onSelectToSpeakStateChangeRequested
*/
chrome.accessibilityPrivate.onSelectToSpeakStateChangeRequested;
// Copyright 2017 The Chromium Authors. All rights reserved.
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -18,7 +18,6 @@ chrome.autofillPrivate = {};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/autofillPrivate#type-AddressField
*/
chrome.autofillPrivate.AddressField = {
FULL_NAME: 'FULL_NAME',
......@@ -39,7 +38,6 @@ chrome.autofillPrivate.AddressField = {
* isLocal: (boolean|undefined),
* isCached: (boolean|undefined)
* }}
* @see https://developer.chrome.com/extensions/autofillPrivate#type-AutofillMetadata
*/
chrome.autofillPrivate.AutofillMetadata;
......@@ -60,7 +58,6 @@ chrome.autofillPrivate.AutofillMetadata;
* languageCode: (string|undefined),
* metadata: (!chrome.autofillPrivate.AutofillMetadata|undefined)
* }}
* @see https://developer.chrome.com/extensions/autofillPrivate#type-AddressEntry
*/
chrome.autofillPrivate.AddressEntry;
......@@ -69,7 +66,6 @@ chrome.autofillPrivate.AddressEntry;
* name: (string|undefined),
* countryCode: (string|undefined)
* }}
* @see https://developer.chrome.com/extensions/autofillPrivate#type-CountryEntry
*/
chrome.autofillPrivate.CountryEntry;
......@@ -80,7 +76,6 @@ chrome.autofillPrivate.CountryEntry;
* isLongField: boolean,
* placeholder: (string|undefined)
* }}
* @see https://developer.chrome.com/extensions/autofillPrivate#type-AddressComponent
*/
chrome.autofillPrivate.AddressComponent;
......@@ -88,7 +83,6 @@ chrome.autofillPrivate.AddressComponent;
* @typedef {{
* row: !Array<!chrome.autofillPrivate.AddressComponent>
* }}
* @see https://developer.chrome.com/extensions/autofillPrivate#type-AddressComponentRow
*/
chrome.autofillPrivate.AddressComponentRow;
......@@ -97,7 +91,6 @@ chrome.autofillPrivate.AddressComponentRow;
* components: !Array<!chrome.autofillPrivate.AddressComponentRow>,
* languageCode: string
* }}
* @see https://developer.chrome.com/extensions/autofillPrivate#type-AddressComponents
*/
chrome.autofillPrivate.AddressComponents;
......@@ -110,7 +103,6 @@ chrome.autofillPrivate.AddressComponents;
* expirationYear: (string|undefined),
* metadata: (!chrome.autofillPrivate.AutofillMetadata|undefined)
* }}
* @see https://developer.chrome.com/extensions/autofillPrivate#type-CreditCardEntry
*/
chrome.autofillPrivate.CreditCardEntry;
......@@ -120,7 +112,6 @@ chrome.autofillPrivate.CreditCardEntry;
* indexOfNewNumber: number,
* countryCode: string
* }}
* @see https://developer.chrome.com/extensions/autofillPrivate#type-ValidatePhoneParams
*/
chrome.autofillPrivate.ValidatePhoneParams;
......@@ -129,7 +120,6 @@ chrome.autofillPrivate.ValidatePhoneParams;
* be assigned a new one and added as a new entry.
* @param {!chrome.autofillPrivate.AddressEntry} address The address entry to
* save.
* @see https://developer.chrome.com/extensions/autofillPrivate#method-saveAddress
*/
chrome.autofillPrivate.saveAddress = function(address) {};
......@@ -137,7 +127,6 @@ chrome.autofillPrivate.saveAddress = function(address) {};
* Gets the list of all countries.
* @param {function(!Array<!chrome.autofillPrivate.CountryEntry>):void} callback
* Callback which will be called with the countries.
* @see https://developer.chrome.com/extensions/autofillPrivate#method-getCountryList
*/
chrome.autofillPrivate.getCountryList = function(callback) {};
......@@ -148,7 +137,6 @@ chrome.autofillPrivate.getCountryList = function(callback) {};
* for a list of valid codes.
* @param {function(!chrome.autofillPrivate.AddressComponents):void} callback
* Callback which will be called with components.
* @see https://developer.chrome.com/extensions/autofillPrivate#method-getAddressComponents
*/
chrome.autofillPrivate.getAddressComponents = function(countryCode, callback) {};
......@@ -156,7 +144,6 @@ chrome.autofillPrivate.getAddressComponents = function(countryCode, callback) {}
* Gets the list of addresses.
* @param {function(!Array<!chrome.autofillPrivate.AddressEntry>):void} callback
* Callback which will be called with the list of addresses.
* @see https://developer.chrome.com/extensions/autofillPrivate#method-getAddressList
*/
chrome.autofillPrivate.getAddressList = function(callback) {};
......@@ -164,14 +151,12 @@ chrome.autofillPrivate.getAddressList = function(callback) {};
* Saves the given credit card. If |card| has an empty string as its ID, it will
* be assigned a new one and added as a new entry.
* @param {!chrome.autofillPrivate.CreditCardEntry} card The card entry to save.
* @see https://developer.chrome.com/extensions/autofillPrivate#method-saveCreditCard
*/
chrome.autofillPrivate.saveCreditCard = function(card) {};
/**
* Removes the entry (address or credit card) with the given ID.
* @param {string} guid ID of the entry to remove.
* @see https://developer.chrome.com/extensions/autofillPrivate#method-removeEntry
*/
chrome.autofillPrivate.removeEntry = function(guid) {};
......@@ -183,7 +168,6 @@ chrome.autofillPrivate.removeEntry = function(guid) {};
* this function.
* @param {function(!Array<string>):void} callback Callback which will be called
* with validated phone numbers.
* @see https://developer.chrome.com/extensions/autofillPrivate#method-validatePhoneNumbers
*/
chrome.autofillPrivate.validatePhoneNumbers = function(params, callback) {};
......@@ -191,7 +175,6 @@ chrome.autofillPrivate.validatePhoneNumbers = function(params, callback) {};
* Gets the list of credit cards.
* @param {function(!Array<!chrome.autofillPrivate.CreditCardEntry>):void}
* callback Callback which will be called with the list of credit cards.
* @see https://developer.chrome.com/extensions/autofillPrivate#method-getCreditCardList
*/
chrome.autofillPrivate.getCreditCardList = function(callback) {};
......@@ -199,7 +182,6 @@ chrome.autofillPrivate.getCreditCardList = function(callback) {};
* Clears the data associated with a wallet card which was saved locally so that
* the saved copy is masked (e.g., "Card ending in 1234").
* @param {string} guid GUID of the credit card to mask.
* @see https://developer.chrome.com/extensions/autofillPrivate#method-maskCreditCard
*/
chrome.autofillPrivate.maskCreditCard = function(guid) {};
......@@ -207,7 +189,6 @@ chrome.autofillPrivate.maskCreditCard = function(guid) {};
* Fired when the address list has changed, meaning that an entry has been
* added, removed, or changed. |entries| The updated list of entries.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/autofillPrivate#event-onAddressListChanged
*/
chrome.autofillPrivate.onAddressListChanged;
......@@ -215,6 +196,5 @@ chrome.autofillPrivate.onAddressListChanged;
* Fired when the credit card list has changed, meaning that an entry has been
* added, removed, or changed. |entries| The updated list of entries.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/autofillPrivate#event-onCreditCardListChanged
*/
chrome.autofillPrivate.onCreditCardListChanged;
......@@ -83,11 +83,11 @@ class _Generator(object):
def _AppendEnumJsDoc(self, c, js_type):
""" Given an Enum Type object, generates the Code for the enum's definition.
"""
(c.Sblock(line='/**', line_prefix=' * ')
.Append('@enum {string}')
.Append(self._js_util.GetSeeLink(self._namespace.name, 'type',
js_type.simple_name))
.Eblock(' */'))
c.Sblock(line='/**', line_prefix=' * ')
c.Append('@enum {string}')
self._js_util.AppendSeeLink(c, self._namespace.name, 'type',
js_type.simple_name)
c.Eblock(' */')
c.Append('%s.%s = {' % (self._GetNamespace(), js_type.name))
def get_property_name(e):
......@@ -136,8 +136,8 @@ class _Generator(object):
else:
self._AppendTypedef(c, js_type.properties)
c.Append(self._js_util.GetSeeLink(self._namespace.name, 'type',
js_type.simple_name))
self._js_util.AppendSeeLink(c, self._namespace.name, 'type',
js_type.simple_name)
c.Eblock(' */')
var = '%s.%s' % (self._GetNamespace(), js_type.simple_name)
......@@ -192,8 +192,7 @@ class _Generator(object):
if (event.description):
c.Comment(event.description, comment_prefix='')
c.Append('@type {!ChromeEvent}')
c.Append(self._js_util.GetSeeLink(self._namespace.name, 'event',
event.name))
self._js_util.AppendSeeLink(c, self._namespace.name, 'event', event.name)
c.Eblock(' */')
c.Append('%s.%s;' % (self._GetNamespace(), event.name))
c.Append()
......
......@@ -89,7 +89,7 @@ namespace fakeApi {
"""
# The output we expect from our fake idl file.
expected_output = """// Copyright %s The Chromium Authors. All rights reserved.
fake_idl_expected = """// Copyright %s The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -221,6 +221,73 @@ chrome.fakeApi.optionalParam = function(callback) {};
*/
chrome.fakeApi.onTrapDetected;""" % datetime.now().year
# A subset of fake_idl. The key difference is that the namespace is private,
# which means that @see links shouldn't be generated.
fake_private_idl = """
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// A totally fake API.
namespace fakeApiPrivate {
enum Greek {
ALPHA,
BETA,
GAMMA,
DELTA
};
dictionary Bar {
long num;
};
interface Events {
// Fired when we realize it's a trap!
static void onTrapDetected(Baz baz);
};
};
"""
fake_private_idl_expected = """// Copyright %s The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file was generated by:
// tools/json_schema_compiler/compiler.py.
// NOTE: The format of types has changed. 'FooType' is now
// 'chrome.fakeApiPrivate.FooType'.
// Please run the closure compiler before committing changes.
// See https://chromium.googlesource.com/chromium/src/+/master/docs/closure_compilation.md
/** @fileoverview Externs generated from namespace: fakeApiPrivate */
/**
* @const
*/
chrome.fakeApiPrivate = {};
/**
* @enum {string}
*/
chrome.fakeApiPrivate.Greek = {
ALPHA: 'ALPHA',
BETA: 'BETA',
GAMMA: 'GAMMA',
DELTA: 'DELTA',
};
/**
* @typedef {{
* num: number
* }}
*/
chrome.fakeApiPrivate.Bar;
/**
* Fired when we realize it's a trap!
* @type {!ChromeEvent}
*/
chrome.fakeApiPrivate.onTrapDetected;""" % datetime.now().year
fake_json = """// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
......@@ -296,7 +363,7 @@ fake_json = """// Copyright 2014 The Chromium Authors. All rights reserved.
}
]"""
json_expected = """// Copyright %s The Chromium Authors. All rights reserved.
fake_json_expected = """// Copyright %s The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -361,12 +428,18 @@ class JsExternGeneratorTest(unittest.TestCase):
def testBasic(self):
namespace = self._GetNamespace(fake_idl, 'fake_api.idl', True)
self.assertMultiLineEqual(expected_output,
self.assertMultiLineEqual(fake_idl_expected,
JsExternsGenerator().Generate(namespace).Render())
def testPrivate(self):
namespace = self._GetNamespace(fake_private_idl, 'fake_api_private.idl',
True)
self.assertMultiLineEqual(fake_private_idl_expected,
JsExternsGenerator().Generate(namespace).Render())
def testJsonWithInlineObjects(self):
namespace = self._GetNamespace(fake_json, 'fake_api.json', False)
self.assertMultiLineEqual(json_expected,
self.assertMultiLineEqual(fake_json_expected,
JsExternsGenerator().Generate(namespace).Render())
......
......@@ -92,8 +92,7 @@ class _Generator(object):
if (event.description):
c.Comment(event.description, comment_prefix='')
c.Append('@type {!ChromeEvent}')
c.Append(self._js_util.GetSeeLink(self._namespace.name, 'event',
event.name))
self._js_util.AppendSeeLink(c, self._namespace.name, 'event', event.name)
c.Eblock(' */')
c.Append('%s.prototype.%s;' % (self._interface, event.name))
......
......@@ -72,7 +72,7 @@ namespace fakeApi {
"""
# The output we expect from our fake idl file.
expected_output = ("""// Copyright %s The Chromium Authors. All rights reserved.
fake_idl_output = ("""// Copyright %s The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -126,7 +126,7 @@ class JsExternGeneratorTest(unittest.TestCase):
def testBasic(self):
namespace = self._GetNamespace(fake_idl, 'fake_api.idl')
self.assertMultiLineEqual(
expected_output,
fake_idl_output,
JsInterfaceGenerator().Generate(namespace).Render())
......
......@@ -97,7 +97,7 @@ class JsUtil(object):
if function.deprecated:
c.Append('@deprecated %s' % function.deprecated)
c.Append(self.GetSeeLink(namespace_name, 'method', function.name))
self.AppendSeeLink(c, namespace_name, 'method', function.name)
c.Eblock(' */')
......@@ -174,14 +174,22 @@ class JsUtil(object):
return Code().Append(js_type.property_type.name)
return Code().Append('?') # TODO(tbreisacher): Make this more specific.
def GetSeeLink(self, namespace_name, object_type, object_name):
"""Returns a @see link for a given API 'object' (type, method, or event).
def AppendSeeLink(self, c, namespace_name, object_type, object_name):
"""Appends a @see link for a given API 'object' (type, method, or event).
"""
# TODO(nigeltao): this should actually be gated on if there is
# documentation, rather than if it's a private API. Most private APIs
# aren't documented, but some are. For example:
# - https://developer.chrome.com/apps/developerPrivate exists
# - https://developer.chrome.com/apps/screenlockPrivate does not
if namespace_name.endswith('Private'):
return
# NOTE(devlin): This is kind of a hack. Some APIs will be hosted on
# developer.chrome.com/apps/ instead of /extensions/, and some APIs have
# '.'s in them (like app.window), which should resolve to 'app_window'.
# Luckily, the doc server has excellent url resolution, and knows exactly
# what we mean. This saves us from needing any complicated logic here.
return ('@see https://developer.chrome.com/extensions/%s#%s-%s' %
(namespace_name, object_type, object_name))
c.Append('@see https://developer.chrome.com/extensions/%s#%s-%s' %
(namespace_name, object_type, object_name))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment