From d3f1a555037d06d25a9952b59c356223f9c5f83b Mon Sep 17 00:00:00 2001 From: Prashant Rawat Date: Sun, 29 May 2022 23:18:04 +0530 Subject: [PATCH] Docstrings for contributor-count and deprecation-helpers services (#8003) * add docstrings for contributor-count service * add docstrings for deprecation-helper service * remove deprecation-helpers service as it is not used anywhere Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com> --- services/contributor-count.js | 22 ++++++++++++++++++++++ services/deprecation-helpers.js | 9 --------- services/deprecation-helpers.spec.js | 15 --------------- 3 files changed, 22 insertions(+), 24 deletions(-) delete mode 100644 services/deprecation-helpers.js delete mode 100644 services/deprecation-helpers.spec.js diff --git a/services/contributor-count.js b/services/contributor-count.js index 60c8664766..373ba393fc 100644 --- a/services/contributor-count.js +++ b/services/contributor-count.js @@ -1,5 +1,18 @@ +/** + * Common functions and utilities for tasks related to contributor count. + * + * @module + */ + import { metric } from './text-formatters.js' +/** + * Determines the color used for a badge based on the contributor count. + * The color varies from red to bright green as the contributor count increases. + * + * @param {number} contributorCount Contributor count + * @returns {string} Badge color + */ function contributorColor(contributorCount) { if (contributorCount > 2) { return 'brightgreen' @@ -10,6 +23,15 @@ function contributorColor(contributorCount) { } } +/** + * Handles rendering concerns of badges that display contributor count. + * Determines the message and color of the badge according to the contributor count. + * + * @param {object} attrs Refer to individual attributes + * @param {string} [attrs.label] If provided then badge label is set to this value + * @param {number} attrs.contributorCount Contributor count + * @returns {object} Badge with label, message and color properties + */ function renderContributorBadge({ label, contributorCount }) { return { label, diff --git a/services/deprecation-helpers.js b/services/deprecation-helpers.js deleted file mode 100644 index fb6ecc6b79..0000000000 --- a/services/deprecation-helpers.js +++ /dev/null @@ -1,9 +0,0 @@ -import { Deprecated } from './index.js' - -function enforceDeprecation(effectiveDate) { - if (Date.now() >= effectiveDate.getTime()) { - throw new Deprecated() - } -} - -export { enforceDeprecation } diff --git a/services/deprecation-helpers.spec.js b/services/deprecation-helpers.spec.js deleted file mode 100644 index 34779dad7f..0000000000 --- a/services/deprecation-helpers.spec.js +++ /dev/null @@ -1,15 +0,0 @@ -import { expect } from 'chai' -import { Deprecated } from '../core/base-service/errors.js' -import { enforceDeprecation } from './deprecation-helpers.js' - -describe('enforceDeprecation', function () { - it('throws Deprecated for a date in the past', function () { - expect(() => enforceDeprecation(new Date())).to.throw(Deprecated) - }) - - it('does not throw for a date in the future', function () { - expect(() => - enforceDeprecation(new Date(Date.now() + 10000)) - ).not.to.throw() - }) -})