Skip to content

Commit

Permalink
Enable Prettier check over all remaining files (open-telemetry#2414)
Browse files Browse the repository at this point in the history
Co-authored-by: Phillip Carter <[email protected]>
  • Loading branch information
chalin and cartermp authored Feb 28, 2023
1 parent 7f1761c commit f0c77d5
Show file tree
Hide file tree
Showing 397 changed files with 1,911 additions and 1,284 deletions.
11 changes: 4 additions & 7 deletions .github/ISSUE_TEMPLATE/DOCS_UPDATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ about: You've found an issue with the documentation.
title: ''
labels: bug
assignees: ''

---

**What needs to be changed?**
Describe the update that is required.
**What needs to be changed?** Describe the update that is required.

**What is the name + path of the page that needs changed?**
The relative path and page title where you found a problem.
**What is the name + path of the page that needs changed?** The relative path
and page title where you found a problem.

**Additional context**
Anything else you can think about that would be helpful.
**Additional context**: anything else you can think about that would be helpful.

_Please delete paragraphs that you did not use before submitting._
7 changes: 2 additions & 5 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ about: For things we should add or change on the site.
title: ''
labels: feature request
assignees: ''

---

**Desired feature or idea.**
What would you like to see happen?
**Desired feature or idea**: What would you like to see happen?

**Additional context**
Anything else you can think about that would be helpful.
**Additional context**: anything else you can think about that would be helpful.

_Please delete paragraphs that you did not use before submitting._
18 changes: 7 additions & 11 deletions .github/ISSUE_TEMPLATE/ISSUE_REPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@ about: For reporting a problem with the opentelemetry.io site.
title: ''
labels: bug
assignees: ''

---

**What happened?**
Describe the problem that occurred.
**What happened?** Describe the problem that occurred.

**What did you expect would happen?**
Describe the expected result/output.
**What did you expect would happen?** Describe the expected result/output.

**What is the name + path of the page where you encountered the issue?**
The relative path and page title where you found a problem.
**What is the name + path of the page where you encountered the issue?** The
relative path and page title where you found a problem.

**What browser, OS, and platform were you using when you encountered the problem?**
Please include the browser version if you know it as well.
**What browser, OS, and platform were you using when you encountered the
problem?** Include the browser version if you know it as well.

**Additional context**
Anything else you can think about that would be helpful.
**Additional context**: anything else you can think about that would be helpful.

_Please delete paragraphs that you did not use before submitting._
5 changes: 4 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE/DOCS_UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Docs PR Checklist

<!--- Just making sure... -->
- [ ] This PR is for a documentation page whose authoritative copy is in the opentelemetry.io repository.

- [ ] This PR is for a documentation page whose authoritative copy is in the
opentelemetry.io repository.
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: npm
directory: /
schedule:
interval: "weekly"
interval: weekly
2 changes: 1 addition & 1 deletion .github/workflows/auto-update-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
schedule:
# hourly at minute 10
- cron: "10 * * * *"
- cron: 10 * * * *

jobs:
auto-update-versions:
Expand Down
20 changes: 9 additions & 11 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
# Base

/.netlify
/.vscode
/iconography
/layouts
package-lock.json
/public
/themes
/tmp

# Ignore content-modules except for Go docs
# Ignore content-modules except for Community pages and Go docs

/content-modules/*
!/content-modules/community
/content-modules/community/*
!/content-modules/community/mission-vision-values.md
!/content-modules/community/roadmap.md

!/content-modules/opentelemetry-go
/content-modules/opentelemetry-go/*
!/content-modules/opentelemetry-go/website_docs
/content-modules/opentelemetry-go/website_docs/**/*
!/content-modules/opentelemetry-go/website_docs/**/*.md

# Temporary while we ramp up use of Prettier
# Ignore generated resources

/.github
/archetypes
/assets/**/*.js
/data
package-lock.json
/public
/resources
/scripts
/templates
5 changes: 2 additions & 3 deletions archetypes/blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ markdown formatter (see below).
If you use images, make sure that your blog post is located in it's own
directory. Put the images into the same directory.

If you have an image stored at
`content/en/{{ .File.Dir }}imagename.png`,
you can reference them like the following:
If you have an image stored at `content/en/{{ .File.Dir }}imagename.png`, you
can reference them like the following:

![Provide a good image description for improved accessibility](imagename.png)

Expand Down
144 changes: 80 additions & 64 deletions assets/js/registrySearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,54 @@ let fuseOptions = {
maxPatternLength: 32,
minMatchCharLength: 1,
keys: [
{ name: "title", weight: 0.8 },
{ name: "description", weight: 0.5 },
{ name: "tags", weight: 0.3 },
{ name: "categories", weight: 0.3 },
{ name: 'title', weight: 0.8 },
{ name: 'description', weight: 0.5 },
{ name: 'tags', weight: 0.3 },
{ name: 'categories', weight: 0.3 },
],
};

// Get searchQuery for queryParams
let pathName = window.location.pathname;
let searchQuery = "";
let selectedLanguage = "all";
let selectedComponent = "all";
let searchQuery = '';
let selectedLanguage = 'all';
let selectedComponent = 'all';

parseUrlParams();

if (pathName.includes("registry")) {
if (pathName.includes('registry')) {
// Run search or display default body
if (searchQuery) {
document.querySelector("#search-query").value = searchQuery;
document.querySelector("#default-body").style.display = "none";
document.querySelector('#search-query').value = searchQuery;
document.querySelector('#default-body').style.display = 'none';
executeSearch(searchQuery);
} else {
let defaultBody = document.querySelector("#default-body");
if (defaultBody.style.display === "none") {
defaultBody.style.display = "block";
let defaultBody = document.querySelector('#default-body');
if (defaultBody.style.display === 'none') {
defaultBody.style.display = 'block';
}
}

if (selectedLanguage!=="all" || selectedComponent!== "all"){
if (selectedLanguage!=="all"){
document.getElementById('languageDropdown').textContent = document.getElementById(`language-item-${selectedLanguage}`).textContent;
if (selectedLanguage !== 'all' || selectedComponent !== 'all') {
if (selectedLanguage !== 'all') {
document.getElementById('languageDropdown').textContent =
document.getElementById(
`language-item-${selectedLanguage}`
).textContent;
}
if (selectedComponent!=="all"){
document.getElementById('componentDropdown').textContent = document.getElementById(`component-item-${selectedComponent}`).textContent;
if (selectedComponent !== 'all') {
document.getElementById('componentDropdown').textContent =
document.getElementById(
`component-item-${selectedComponent}`
).textContent;
}
updateFilters();
}
}

// Runs search through Fuse for fuzzy search
function executeSearch(searchQuery) {
fetch("/ecosystem/registry/index.json")
fetch('/ecosystem/registry/index.json')
.then((res) => res.json())
.then((json) => {
let fuse = new Fuse(json, fuseOptions);
Expand All @@ -59,8 +65,8 @@ function executeSearch(searchQuery) {
if (results.length > 0) {
populateResults(results);
} else {
document.querySelector("#search-results").innerHTML +=
"<p>No matches found</p>";
document.querySelector('#search-results').innerHTML +=
'<p>No matches found</p>';
}
});
}
Expand All @@ -69,16 +75,16 @@ function executeSearch(searchQuery) {
function populateResults(results) {
results.forEach((result, key) => {
let contents = result.item.description;
let snippet = "";
let snippet = '';
let snippetHighlights = [];

if (fuseOptions.tokenize) {
snippetHighlights.push(searchQuery);
} else {
result.matches.forEach((match) => {
if (match.key === "tags" || match.key === "categories") {
if (match.key === 'tags' || match.key === 'categories') {
snippetHighlights.push(match.value);
} else if (match.key === "description") {
} else if (match.key === 'description') {
start =
match.indices[0][0] - summaryInclude > 0
? match.indices[0][0] - summaryInclude
Expand All @@ -103,8 +109,9 @@ function populateResults(results) {
}

// Pull template from hugo template definition
let templateDefinition = document.querySelector("#search-result-template")
.innerHTML;
let templateDefinition = document.querySelector(
'#search-result-template'
).innerHTML;

// Replace values from template with search results
let output = render(templateDefinition, {
Expand All @@ -120,7 +127,7 @@ function populateResults(results) {
snippet: snippet,
otVersion: result.item.otVersion,
});
document.querySelector("#search-results").innerHTML += output;
document.querySelector('#search-results').innerHTML += output;
});
}

Expand All @@ -138,78 +145,87 @@ function render(templateString, data) {
copy = copy.replace(conditionalMatches[0], conditionalMatches[2]);
} else {
//not valid, remove entire section
copy = copy.replace(conditionalMatches[0], "");
copy = copy.replace(conditionalMatches[0], '');
}
}
templateString = copy;

//now any conditionals removed we can do simple substitution
let key, find, re;
for (key in data) {
find = "\\$\\{\\s*" + key + "\\s*\\}";
re = new RegExp(find, "g");
find = '\\$\\{\\s*' + key + '\\s*\\}';
re = new RegExp(find, 'g');
templateString = templateString.replace(re, data[key]);
}
return templateString;
}

if (pathName.includes("registry")) {
if (pathName.includes('registry')) {
document.addEventListener('DOMContentLoaded', (event) => {
let languageList = document.getElementById('languageFilter').querySelectorAll('.dropdown-item')
let typeList = document.getElementById('componentFilter').querySelectorAll('.dropdown-item')
languageList.forEach((element) => element.addEventListener('click', function(evt) {
let val = evt.target.getAttribute('value')
selectedLanguage = val;
document.getElementById('languageDropdown').textContent = evt.target.textContent;
setInput("language", val);
updateFilters();
}))
typeList.forEach((element) => element.addEventListener('click', function(evt) {
let val = evt.target.getAttribute('value')
selectedComponent = val;
document.getElementById('componentDropdown').textContent = evt.target.textContent;
setInput("component", val);
updateFilters();
}))
})
let languageList = document
.getElementById('languageFilter')
.querySelectorAll('.dropdown-item');
let typeList = document
.getElementById('componentFilter')
.querySelectorAll('.dropdown-item');
languageList.forEach((element) =>
element.addEventListener('click', function (evt) {
let val = evt.target.getAttribute('value');
selectedLanguage = val;
document.getElementById('languageDropdown').textContent =
evt.target.textContent;
setInput('language', val);
updateFilters();
})
);
typeList.forEach((element) =>
element.addEventListener('click', function (evt) {
let val = evt.target.getAttribute('value');
selectedComponent = val;
document.getElementById('componentDropdown').textContent =
evt.target.textContent;
setInput('component', val);
updateFilters();
})
);
});
}


function setInput(key, value){
function setInput(key, value) {
document.getElementById(`input-${key}`).value = value;
var queryParams = new URLSearchParams(window.location.search);
queryParams.set(key, value);
history.replaceState(null, null, "?"+queryParams.toString());
history.replaceState(null, null, '?' + queryParams.toString());
}

// Filters items based on language and component filters
function updateFilters() {
let allItems = [...document.getElementsByClassName("media")];
if (selectedComponent === "all" && selectedLanguage === "all") {
allItems.forEach((element) => element.classList.remove("d-none"));
let allItems = [...document.getElementsByClassName('media')];
if (selectedComponent === 'all' && selectedLanguage === 'all') {
allItems.forEach((element) => element.classList.remove('d-none'));
} else {
allItems.forEach((element) => {
const dc = element.dataset.registrytype;
const dl = element.dataset.registrylanguage;
if (
(dc === selectedComponent || selectedComponent === "all") &&
(dl === selectedLanguage || selectedLanguage === "all")
(dc === selectedComponent || selectedComponent === 'all') &&
(dl === selectedLanguage || selectedLanguage === 'all')
) {
element.classList.remove("d-none");
element.classList.remove('d-none');
} else if (dc === selectedComponent && dl !== selectedLanguage) {
element.classList.add("d-none");
element.classList.add('d-none');
} else if (dl === selectedLanguage && dc !== selectedComponent) {
element.classList.add("d-none");
element.classList.add('d-none');
} else {
element.classList.add("d-none");
element.classList.add('d-none');
}
});
}
}

function parseUrlParams(){
function parseUrlParams() {
let urlParams = new URLSearchParams(window.location.search);
searchQuery = urlParams.get("s");
selectedLanguage = urlParams.get("language") || "all";
selectedComponent = urlParams.get("component") || "all";
searchQuery = urlParams.get('s');
selectedLanguage = urlParams.get('language') || 'all';
selectedComponent = urlParams.get('component') || 'all';
}
Loading

0 comments on commit f0c77d5

Please sign in to comment.