Skip to content

Repo sync #37935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/webhooks/types-of-webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ You can use the {% data variables.product.github %} web interface to manage a {%

## {% data variables.product.prodname_sponsors %} webhooks

You can create webhooks to subscribe to events relating to {% data variables.product.prodname_sponsors %}. You can only create up to {% ifversion ghes %}250{% else %}20{% endif %} webhooks for a {% data variables.product.prodname_sponsors %} account.
You can create webhooks to subscribe to events relating to {% data variables.product.prodname_sponsors %}. You can only create up to 20 webhooks for a {% data variables.product.prodname_sponsors %} account.

You must be an account owner or have admin access in the sponsored account to manage sponsorship webhooks.

Expand Down
1 change: 0 additions & 1 deletion data/reusables/contributing/content-linter-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
| GHD018 | liquid-syntax | Markdown content must use valid Liquid | error | liquid |
| GHD019 | liquid-if-tags | Liquid `ifversion` tags should be used instead of `if` tags when the argument is a valid version | error | liquid, versioning |
| GHD020 | liquid-ifversion-tags | Liquid `ifversion` tags should contain valid version names as arguments | error | liquid, versioning |
| GHD022 | liquid-ifversion-versions | Liquid `ifversion` (and `elsif`) should not always be true | warning | liquid, versioning |
| GHD035 | rai-reusable-usage | RAI articles and reusables can only reference reusable content in the data/reusables/rai directory | error | feature, rai |
| GHD036 | image-no-gif | Image must not be a gif, styleguide reference: contributing/style-guide-and-content-model/style-guide.md#images | error | images |
| GHD038 | expired-content | Expired content must be remediated. | error | expired |
Expand Down
6 changes: 5 additions & 1 deletion data/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ search:
references: Additional docs
loading_status_message: Loading Copilot response...
done_loading_status_message: Done loading Copilot response
unable_to_answer: Sorry, I'm unable to answer that question. Check that you selected the correct GitHub version or try a different query.
copy_answer: Copy answer
copied_announcement: Copied!
thumbs_up: This answer was helpful
thumbs_down: This answer was not helpful
thumbs_announcement: Thank you for your feedback!
back_to_search: Back to search
responses:
unable_to_answer: Sorry, I'm unable to answer that question. Check that you selected the correct GitHub version or try a different question.
query_too_large: Sorry, your question is too long. Please try shortening it and asking again.
asked_too_many_times: Sorry, you've asked too many questions in a short time period. Please wait a few minutes and try again.
invalid_query: Sorry, I'm unable to answer that question. Please try asking a different question.
failure:
general_title: There was an error loading search results.
ai_title: There was an error loading Copilot.
Expand Down
106 changes: 105 additions & 1 deletion src/content-linter/lib/helpers/liquid-utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Tokenizer } from 'liquidjs'
import { Tokenizer, TokenKind } from 'liquidjs'

import { deprecated } from '#src/versions/lib/enterprise-server-releases.js'

const liquidTokenCache = new Map()

Expand Down Expand Up @@ -26,6 +28,7 @@ export const TAG_OPEN = '{{'
export const TAG_CLOSE = '}}'

export const conditionalTags = ['if', 'elseif', 'unless', 'case', 'ifversion']
const CONDITIONAL_TAG_NAMES = ['if', 'ifversion', 'elsif', 'else', 'endif']

export function getPositionData(token, lines) {
// Liquid indexes are 0-based, but we want to
Expand All @@ -46,3 +49,104 @@ export function getPositionData(token, lines) {
}
return { lineNumber, column: count, length: end - begin }
}

/* When looking for unused Liquid `ifversion` tags, there
* are a few ways content can be updated to remove
* deprecated conditional statements. This function is
* specific to tags in a statement that are removed along
* with the content in the statement. For example:
*
* {% ifversion < 1.0 %}This is removed{% endif %}
*
* Returns an array of error objects in the format expected
* by Markdownlint:
* [ { lineNumber: 1, column: 1, deleteCount: 3, }]
*/
export function getContentDeleteData(token, tokenEnd, lines) {
const { lineNumber, column } = getPositionData(token, lines)
const errorInfo = []
let begin = column - 1
// Subtract one from end of next token tag. The end of the
// current tag is one position before that.
const length = tokenEnd - token.begin

if (lines[lineNumber - 1].slice(begin).length >= length) {
return [{ lineNumber, column, deleteCount: length }]
}

let remainingLength = length
let incLineNumber = 0
while (remainingLength > 0) {
const zeroBasedLineNumber = lineNumber - 1 + incLineNumber
const line = lines[zeroBasedLineNumber]
const lineLength = line.length
let deleteCount
if (begin !== 0) {
deleteCount = line.slice(begin).length
remainingLength -= deleteCount + 1
} else if (remainingLength >= lineLength) {
deleteCount = -1
remainingLength -= lineLength + 1
} else {
deleteCount = remainingLength
remainingLength -= deleteCount
}
errorInfo.push({ lineNumber: zeroBasedLineNumber + 1, column: begin + 1, deleteCount })
begin = 0
incLineNumber++
}
return errorInfo
}

// This function returns all ifversion conditional statement tags
// and filters out any `if` conditional statements (including the
// related elsif, else, and endif tags).
// Docs doesn't use the standard `if` tag for versioning, instead the
// `ifversion` tag is used.
export function getLiquidIfVersionTokens(content) {
const tokens = getLiquidTokens(content)
.filter((token) => token.kind === TokenKind.Tag)
.filter((token) => CONDITIONAL_TAG_NAMES.includes(token.name))

let inIfStatement = false
const ifVersionTokens = []
for (const token of tokens) {
if (token.name === 'if') {
inIfStatement = true
continue
}
if (inIfStatement && token.name !== 'endif') continue
if (inIfStatement && token.name === 'endif') {
inIfStatement = false
continue
}
ifVersionTokens.push(token)
}
return ifVersionTokens
}

export function getSimplifiedSemverRange(release) {
// Liquid conditionals only use the format > or < but not
// >= or <=. Not sure exactly why.
// if startswith >, we'll check to see if the release number
// is in the deprecated list, meaning the > case can be removed
// or changed to '*'.
const releaseStrings = release.split(' ')
const releaseToCheckIndex = releaseStrings.indexOf('>') + 1
const releaseToCheck = releaseStrings[releaseToCheckIndex]

// If the release is not part of a range and the release number
// is deprecated, return '*' to indicate all ghes releases.
if (deprecated.includes(releaseToCheck) && releaseStrings.length === 2) {
return '*'
}

// When the release is a range and the lower range (e.g., `ghes > 3.12`)
// is now deprecated, return an empty string.
// Otherwise, return the release as-is.
const newRelease = deprecated.includes(releaseToCheck)
? release.replace(`> ${releaseToCheck}`, '')
: release

return newRelease
}
7 changes: 7 additions & 0 deletions src/content-linter/lib/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,10 @@ export function getFrontmatter(lines) {
if (Object.keys(data).length === 0) return null
return data
}

export function getFrontmatterLines(lines) {
const indexStart = lines.indexOf('---')
if (indexStart === -1) return []
const indexEnd = lines.indexOf('---', indexStart + 1)
return lines.slice(indexStart, indexEnd + 1)
}
6 changes: 4 additions & 2 deletions src/content-linter/lib/linting-rules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ import { liquidDataReferencesDefined, liquidDataTagFormat } from './liquid-data-
import { frontmatterSchema } from './frontmatter-schema.js'
import { codeAnnotations } from './code-annotations.js'
import { frontmatterLiquidSyntax, liquidSyntax } from './liquid-syntax.js'
import { liquidIfTags, liquidIfVersionTags, liquidIfVersionVersions } from './liquid-versioning.js'
import { liquidIfTags, liquidIfVersionTags } from './liquid-versioning.js'
import { raiReusableUsage } from './rai-reusable-usage.js'
import { imageNoGif } from './image-no-gif.js'
import { expiredContent, expiringSoon } from './expired-content.js'
import { tableLiquidVersioning } from './table-liquid-versioning.js'
import { thirdPartyActionPinning } from './third-party-action-pinning.js'
import { liquidTagWhitespace } from './liquid-tag-whitespace.js'
import { linkQuotation } from './link-quotation.js'
import { liquidIfversionVersions } from './liquid-ifversion-versions.js'

const noDefaultAltText = markdownlintGitHub.find((elem) =>
elem.names.includes('no-default-alt-text'),
Expand Down Expand Up @@ -72,7 +73,7 @@ export const gitHubDocsMarkdownlint = {
liquidSyntax,
liquidIfTags,
liquidIfVersionTags,
liquidIfVersionVersions,
liquidIfversionVersions,
raiReusableUsage,
imageNoGif,
expiredContent,
Expand All @@ -81,5 +82,6 @@ export const gitHubDocsMarkdownlint = {
thirdPartyActionPinning,
liquidTagWhitespace,
linkQuotation,
liquidIfversionVersions,
],
}
Loading
Loading