Commit 0ed6cd1a authored by Henrique Nakashima's avatar Henrique Nakashima Committed by Commit Bot

Shorten package names in dependency visualization

The shortener is Chrome-specific. It replaces:
"org.chromium.chrome.browser.foo" with ".c.b.foo"

Also git ignore json_graph.txt

Bug: 1093962
Change-Id: Id1d84f7b2478672c7db6ef6370bb86654687cdc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2254096
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: default avatarSamuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780908}
parent c428074e
node_modules/
json_graph.txt
package-lock.json
// Copyright 2020 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.
/**
* Shortens a package name to be displayed in the svg.
* @param {string} name The full package name to shorten.
* @return {string} The shortened package name.
*/
function shortenPackageName(name) {
return name
.replace('org.chromium.', '.')
.replace('chrome.browser.', 'c.b.');
}
export {
shortenPackageName,
};
......@@ -3,14 +3,7 @@
// found in the LICENSE file.
import {Node, Edge, Graph} from './graph_model.js';
/**
* TODO(yjlong): Compute the "shortest disambiguated name" in Python and include
* it in the JSON so we do not need to do this calculation.
* @param {number} name The full package name to shorten.
* @return {number} The shortened package name.
*/
const shortName = name => name.substring(name.lastIndexOf('.') + 1);
import {shortenPackageName} from './chrome_hooks.js';
/**
* A graph read from JSON.
......@@ -28,7 +21,7 @@ const shortName = name => name.substring(name.lastIndexOf('.') + 1);
function parseGraphFromJson(jsonGraph) {
const graph = new Graph();
for (const nodeData of jsonGraph.nodes) {
const node = new Node(nodeData.name, shortName(nodeData.name));
const node = new Node(nodeData.name, shortenPackageName(nodeData.name));
graph.addNodeIfNew(node);
}
for (const edgeData of jsonGraph.edges) {
......
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