fix(tl): better {@link} generation from documentation

This commit is contained in:
teidesu 2022-08-12 17:46:04 +03:00
parent 9b027425dd
commit 16fdd5ded1
4 changed files with 12 additions and 3 deletions

View file

@ -3,7 +3,7 @@ import { groupTlEntriesByNamespace, splitNameToNamespace } from '../utils'
import { camelToPascal, indent, jsComment, snakeToCamel } from './utils'
import { errorCodeToClassName, generateCodeForErrors } from './errors'
const PRIMITIVE_TO_TS: Record<string, string> = {
export const PRIMITIVE_TO_TS: Record<string, string> = {
int: 'number',
long: 'Long',
int53: 'number',
@ -16,6 +16,8 @@ const PRIMITIVE_TO_TS: Record<string, string> = {
true: 'boolean',
null: 'null',
any: 'any',
boolFalse: 'false',
boolTrue: 'true',
}
function fullTypeName(

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -2,6 +2,7 @@ import { TlEntry, TlFullSchema } from '@mtcute/tl-utils/src/types'
import cheerio from 'cheerio'
import { splitNameToNamespace } from '@mtcute/tl-utils/src/utils'
import { camelToPascal, snakeToCamel } from '@mtcute/tl-utils/src/codegen/utils'
import { PRIMITIVE_TO_TS } from '@mtcute/tl-utils/src/codegen/types'
import {
API_SCHEMA_JSON_FILE,
BLOGFORK_DOMAIN,
@ -51,6 +52,12 @@ function normalizeLinks(url: string, el: Cheerio): void {
) {
let [, type, name] = m
const [ns, n] = splitNameToNamespace(name)
if (PRIMITIVE_TO_TS[n]) {
it.replaceWith(PRIMITIVE_TO_TS[n])
return
}
let q = camelToPascal(snakeToCamel(n))
if (type === 'method' || type === 'constructor') {