docs(tl): replace male pronouns with gender-neutral
This commit is contained in:
parent
ecca291eba
commit
685d75effd
3 changed files with 42 additions and 16 deletions
|
@ -470,3 +470,8 @@ regex:
|
||||||
repl: stickerset
|
repl: stickerset
|
||||||
- regex: \bonly "foursquare" needs\b
|
- regex: \bonly "foursquare" needs\b
|
||||||
repl: only "foursquare" and "gplaces" need
|
repl: only "foursquare" and "gplaces" need
|
||||||
|
# gender-neutral pronouns
|
||||||
|
- regex: \bhis\b
|
||||||
|
repl: their
|
||||||
|
- regex: \bhim\b
|
||||||
|
repl: them
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5,11 +5,7 @@
|
||||||
// it to the resulting JSON.
|
// it to the resulting JSON.
|
||||||
|
|
||||||
async function applyDescriptionsFile(input, yaml) {
|
async function applyDescriptionsFile(input, yaml) {
|
||||||
const {
|
const { objects: byObjects, arguments: byArguments, regex: byRegex } = yaml
|
||||||
objects: byObjects,
|
|
||||||
arguments: byArguments,
|
|
||||||
regex: byRegex,
|
|
||||||
} = yaml
|
|
||||||
|
|
||||||
// util function to handle text and objects with text for overrides
|
// util function to handle text and objects with text for overrides
|
||||||
function applyOverwrite(where, what) {
|
function applyOverwrite(where, what) {
|
||||||
|
@ -94,7 +90,10 @@ async function applyDescriptionsFile(input, yaml) {
|
||||||
for (const filter of rule.filters) {
|
for (const filter of rule.filters) {
|
||||||
if (filter.objType && filter.objType[0] !== key[0])
|
if (filter.objType && filter.objType[0] !== key[0])
|
||||||
break args
|
break args
|
||||||
if (filter.type && !filter.type.split(' | ').includes(arg.type))
|
if (
|
||||||
|
filter.type &&
|
||||||
|
!filter.type.split(' | ').includes(arg.type)
|
||||||
|
)
|
||||||
break args
|
break args
|
||||||
|
|
||||||
// noinspection EqualityComparisonWithCoercionJS
|
// noinspection EqualityComparisonWithCoercionJS
|
||||||
|
@ -111,22 +110,25 @@ async function applyDescriptionsFile(input, yaml) {
|
||||||
// process byRegex
|
// process byRegex
|
||||||
function replaceRegex(obj, regex) {
|
function replaceRegex(obj, regex) {
|
||||||
if (!obj.description) return
|
if (!obj.description) return
|
||||||
if (!regex._cached) regex._cached = new RegExp(regex.regex, regex.flags)
|
if (!regex._cached) {
|
||||||
obj.description = obj.description.replace(
|
let flags = regex.flags || ''
|
||||||
regex._cached,
|
if (flags.indexOf('g') === -1) flags += 'g'
|
||||||
regex.repl
|
|
||||||
)
|
regex._cached = new RegExp(regex.regex, flags)
|
||||||
|
}
|
||||||
|
obj.description = obj.description.replace(regex._cached, regex.repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.values(index).forEach((obj) => {
|
Object.values(index).forEach((obj) => {
|
||||||
for (const regex of byRegex) {
|
for (const regex of byRegex) {
|
||||||
replaceRegex(obj, regex)
|
replaceRegex(obj, regex)
|
||||||
|
|
||||||
if (obj.arguments) obj.arguments.forEach((arg) => replaceRegex(arg, regex))
|
if (obj.arguments)
|
||||||
|
obj.arguments.forEach((arg) => replaceRegex(arg, regex))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
debugger
|
return input
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -134,8 +136,27 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
applyDescriptionsFile(require('../raw-schema.json'))
|
const fs = require('fs')
|
||||||
.then(console.log)
|
const path = require('path')
|
||||||
|
const yaml = require('js-yaml')
|
||||||
|
|
||||||
|
applyDescriptionsFile(
|
||||||
|
JSON.parse(
|
||||||
|
fs.readFileSync(path.join(__dirname, '../raw-schema.json'), 'utf-8')
|
||||||
|
),
|
||||||
|
yaml.load(
|
||||||
|
fs.readFileSync(
|
||||||
|
path.join(__dirname, '../descriptions.yaml'),
|
||||||
|
'utf-8'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then((res) =>
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(__dirname, '../raw-schema.json'),
|
||||||
|
JSON.stringify(res)
|
||||||
|
)
|
||||||
|
)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|
Loading…
Reference in a new issue