From da20e44d5293baf5341912ba9d072515cab8bb5c Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Wed, 6 Jan 2021 13:25:59 -0500 Subject: [PATCH] Add subdependencies --- docs/assets/plugins/metadata/metadata.js | 40 ++++++++++-------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/docs/assets/plugins/metadata/metadata.js b/docs/assets/plugins/metadata/metadata.js index aa44de7d9..18c5dfdb1 100644 --- a/docs/assets/plugins/metadata/metadata.js +++ b/docs/assets/plugins/metadata/metadata.js @@ -175,32 +175,24 @@ return table.outerHTML; } - function createDependenciesList(dependencies) { + function createDependenciesList(dependencies, dependencyGraph) { + const all = [...dependencies]; const ul = document.createElement('ul'); - ul.innerHTML = ` - ${dependencies - .map( - dependency => ` -
  • ${escapeHtml(dependency)}
  • - ` - ) - .join('')} - `; - return ul.outerHTML; - } + // Gather subdependencies from the dependency graph + Object.keys(dependencyGraph).map(key => { + dependencyGraph[key].map(subdep => { + if (!all.includes(subdep)) { + all.push(subdep); + } + }); + }); - function createDependentsList(dependents) { - const ul = document.createElement('ul'); - ul.innerHTML = ` - ${dependents - .map( - dependent => ` -
  • ${escapeHtml(dependent)}
  • - ` - ) - .join('')} - `; + all.sort().map(dependency => { + const li = document.createElement('li'); + li.innerHTML = `${dependency}`; + ul.appendChild(li); + }); return ul.outerHTML; } @@ -384,7 +376,7 @@ This component has the following dependencies. If you're not using the lazy loader, be sure to import and register these components in addition to ${tag}. - ${createDependenciesList(data.dependencies)} + ${createDependenciesList(data.dependencies, data.dependencyGraph)} `; }