Skip to content
Draft
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
3 changes: 2 additions & 1 deletion packages/api-model/src/builtins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export function elixirStdlibHref(path: string, name?: string, arity?: number, ki
* removed name stays unlinked instead of pointing at a page without it.
*/
const ELIXIR_STDLIB_FUNCTIONS: readonly (readonly [module: string, name: string, arity: number])[] = [
['Enum', 'member?', 2], ['JSON', 'encode!', 1], ['Supervisor', 'start_child', 2], ['Supervisor', 'restart_child', 2],
['Enum', 'map', 2], ['Enum', 'member?', 2], ['Enum', 'to_list', 1], ['GenServer', 'call', 2],
['JSON', 'encode!', 1], ['Supervisor', 'start_child', 2], ['Supervisor', 'restart_child', 2],
]

/** The typespec grammar names these without a module. */
Expand Down
2 changes: 1 addition & 1 deletion packages/api-model/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export { extractHaskellArtifact } from './languages/haskell.ts'
export { extractProject } from './project.ts'
export { resolvePublicIds } from './reexports.ts'
export { SymbolIndex, keywordArgument, parameterId, typeParameterId, type LinkTarget, type KeywordHelp, type TypeParameterBinding } from './link.ts'
export { boundLabel, parseTypeParameter, parseTypeParameters, typeParameterList, typeParametersOf, withTypeParameterDocs } from './type-params.ts'
export { boundLabel, findTopLevel, parseTypeParameter, parseTypeParameters, typeParameterList, typeParametersOf, withTypeParameterDocs } from './type-params.ts'
export { tokenizeDoc, docSummaryText, referencesIn, type DocSpan } from './doc/roles.ts'
export { writeInventory, writeInventoryEntries, readInventory, inventoryType, isSymbolEntry, symbolEntries, NON_SYMBOL_ROLES, type InventoryEntry } from './inventory.ts'
export { targetKey, targetEntries, compatibilityEntries, type InventoryTarget } from './targets.ts'
Expand Down
6 changes: 6 additions & 0 deletions packages/api-model/src/prose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ export function notApiReason(text: string, port?: string): string | undefined {
const t = text.trim()
if (port === 'haskell' && /^(?:next-X\.Y|X\.Y(?:[a-z]|-rcN?)?)$/.test(t)) return 'tmux release pattern'
if (port === 'haskell' && t === 'With') return 'deadline variant suffix'
if (port === 'elixir') {
// The overview names these planned features before they have reference pages.
if (['Query', 'Batch', 'Plan', 'Observation', 'Tracker'].includes(t)) return 'planned Elixir feature'
if (t === 'ApplicationConnection') return 'example module'
if (t === 'r1:N') return 'capture row prefix'
}
for (const { why, test } of NOT_API) {
if (port === 'lisp' && why === 'configuration key' && /^libtmux(?:\.[\w-]+)*:[\w-]+$/.test(t)) continue
if (test.test(t)) return why
Expand Down
4 changes: 3 additions & 1 deletion packages/api-model/src/type-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ const julia: Parser = (text) => {
/** `when item: Bound` of a spec, or the bare variable of `t(item)`. */
const elixir: Parser = (text) => {
const match = /^([a-z_]\w*)\s*(?::\s*([\s\S]+))?$/.exec(text.trim())
return match ? [make({ name: match[1]!, bound: match[2] })] : []
if (!match) return []
const bound = match[2]?.trim()
return [make({ name: match[1]!, bound: bound === 'var' ? undefined : bound })]
}

const ruby: Parser = (text) => {
Expand Down
14 changes: 14 additions & 0 deletions packages/api-model/test/mentions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ describe('distribution files, wire format names and query paths', () => {
})
})

describe('Elixir lifecycle prose', () => {
it('leaves the known non-API spans plain without hiding unknown names', () => {
for (const text of ['Query', 'Batch', 'Plan', 'Observation', 'Tracker']) {
expect(notApiReason(text, 'elixir'), text).toBe('planned Elixir feature')
expect(notApiReason(text, 'ruby'), text).toBeUndefined()
}
expect(notApiReason('ApplicationConnection', 'elixir')).toBe('example module')
expect(notApiReason('r1:N', 'elixir')).toBe('capture row prefix')
for (const text of ['LibTmux.Query', 'MissingApi', 'Enum.not_defined/1']) {
expect(notApiReason(text, 'elixir'), text).toBeUndefined()
}
})
})

describe('a Raku core type', () => {
const raku = { port: 'raku', version: '0', symbols: [{ id: 'LibTmux::Server', name: 'Server', kind: 'class', signatures: [], docs: [] }] }
const models = { raku } as unknown as Record<string, ApiModel>
Expand Down
2 changes: 2 additions & 0 deletions packages/api-model/test/type-parameters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ describe('type parameter declarations, read apart', () => {
['julia', 'I<:LibTmux.EntityID', [{ name: 'I', bound: 'LibTmux.EntityID' }]],
['julia', ':session', []],
['julia', 'LibTmux.BufferID', []],
['elixir', 'value: var', [{ name: 'value' }]],
['elixir', 'value: var()', [{ name: 'value', bound: 'var()' }]],
['ruby', 'unchecked out T < Foo = Bar', [{ name: 'T', modifier: 'out', bound: 'Foo', default: 'Bar' }]],
['py', 'T: int = str', [{ name: 'T', bound: 'int', default: 'str' }]],
['py', '**P', [{ name: 'P', modifier: '**' }]],
Expand Down
6 changes: 4 additions & 2 deletions scripts/lib/api-destinations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { BUILTINS } from '../../packages/api-model/src/builtins.ts'
import { Resolver, SymbolIndex, conceptNotes, decideMention, proseTexts, looksLikeApiMention, notASymbol, sourceUrl } from '../../packages/api-model/src/index.ts'
import { fromMarkdown } from 'mdast-util-from-markdown'
import { parseApiProse } from '../../packages/api-model/src/reference.ts'
import { SOURCE_GUIDE_PORTS } from '../../site/src/lib/port-documentation.ts'
import { apiDocLinkRewriter, SOURCE_GUIDE_PORTS } from '../../site/src/lib/port-documentation.ts'
import { stagedPortGuides } from '../stage-port-docs.mjs'
import { powerShellCommonParameterHref, powerShellCommonParameterLabel } from '../../site/src/lib/powershell-common-parameters.ts'
import { KNOWN_PORTS, resolvePortBody, resolvePortData } from '../../site/src/lib/workspace-shared-slots.ts'
Expand Down Expand Up @@ -231,7 +231,9 @@ export function apiIndexes({ root = ROOT } = {}) {

const indexes = {}
for (const [port, model] of Object.entries(models)) {
const index = new SymbolIndex(model.symbols, (symbol) => `/${symbol.slug ?? symbol.id}/`, port)
const sourceVersion = model.sources?.find((source) => source.product === 'core')?.version
const index = new SymbolIndex(model.symbols, (symbol) => `/${symbol.slug ?? symbol.id}/`, port,
apiDocLinkRewriter(port, `/${port}/`, sourceVersion))
for (const inventory of inventories) {
if (inventory.langs.includes(port)) index.addInventory(inventory.baseUrl, inventory.entries, inventory.langs, inventory.project)
}
Expand Down
Loading
Loading