Skip to content
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

Allow TN links with IDs and more varieties of Bible links #140

Merged
merged 6 commits into from
Feb 1, 2021
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
13 changes: 11 additions & 2 deletions makeNoticeList.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
#!/usr/bin/env python3
#
# Last modified: 2021-01-28 by RJH
#

import os
import datetime

"""
Scans all the source files to find all notices,
sorts them,
and then lists them in noticeList.txt.
"""

noticeList = []

for root, dirs, files in os.walk('.'):
for name in files:
if '/dist/' not in root \
if '/src/' in root \
and name.endswith('.js') or name.endswith('.ts'):
# print("file", name, os.path.join(root, name))
with open(os.path.join(root, name), 'rt') as sourceFile:
for n, line in enumerate(sourceFile, start=1):
if ('addNotice' in line or '{ priority:' in line) \
and 'function addNotice' not in line \
and 'console.log' not in line and 'console.assert' not in line \
and 'console.log' not in line and 'userLog' not in line and 'debugLog' not in line \
and 'console.assert' not in line and not 'parameterAssert' in line \
and 'oticeEntry' not in line \
and 'grammarCheckResult.error' not in line \
and 'MORE SIMILAR' not in line \
Expand Down
486 changes: 142 additions & 344 deletions noticeList.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "uw-content-validation",
"description": "Functions for Checking Door43.org Scriptural Content/Resources.",
"version": "1.1.0",
"version": "1.1.1",
"private": false,
"homepage": "https://unfoldingword.github.io/uw-content-validation/",
"repository": {
Expand Down
29 changes: 23 additions & 6 deletions src/__tests__/__snapshots__/book-package-check.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4095,7 +4095,7 @@ Object {
"filename": "en_tn_08-RUT.tsv",
"lineNumber": 19,
"location": " in en RUT book package from unfoldingWord master branch",
"message": "Link to TA should also be in SupportReference",
"message": "Should have a SupportReference when OccurrenceNote has a TA link",
"priority": 786,
"repoCode": "TN",
"repoName": "en_tn",
Expand Down Expand Up @@ -4148,7 +4148,7 @@ Object {
"filename": "en_tn_08-RUT.tsv",
"lineNumber": 94,
"location": " in en RUT book package from unfoldingWord master branch",
"message": "Link to TA should also be in SupportReference",
"message": "Should have a SupportReference when OccurrenceNote has a TA link",
"priority": 786,
"repoCode": "TN",
"repoName": "en_tn",
Expand All @@ -4172,6 +4172,23 @@ Object {
"rowID": "ab60",
"username": "unfoldingWord",
},
Object {
"C": "2",
"V": "12",
"bookID": "RUT",
"details": "need to carefully check [\\"[Doublet](../figs-doublet/01.md)\\"]",
"extra": "TN",
"fieldName": "OccurrenceNote",
"filename": "en_tn_08-RUT.tsv",
"lineNumber": 110,
"location": " in en RUT book package from unfoldingWord master branch",
"message": "Unusual [ ]( ) link(s)—not normal Bible or TN links",
"priority": 648,
"repoCode": "TN",
"repoName": "en_tn",
"rowID": "gnn5",
"username": "unfoldingWord",
},
Object {
"C": "3",
"V": "12",
Expand All @@ -4183,7 +4200,7 @@ Object {
"filename": "en_tn_08-RUT.tsv",
"lineNumber": 184,
"location": " in en RUT book package from unfoldingWord master branch",
"message": "Link to TA should also be in SupportReference",
"message": "Should have a SupportReference when OccurrenceNote has a TA link",
"priority": 786,
"repoCode": "TN",
"repoName": "en_tn",
Expand Down Expand Up @@ -4219,7 +4236,7 @@ Object {
"filename": "en_tn_08-RUT.tsv",
"lineNumber": 230,
"location": " in en RUT book package from unfoldingWord master branch",
"message": "Link to TA should also be in SupportReference",
"message": "Should have a SupportReference when OccurrenceNote has a TA link",
"priority": 786,
"repoCode": "TN",
"repoName": "en_tn",
Expand Down Expand Up @@ -16687,7 +16704,7 @@ Object {
"filename": "en_tn_57-TIT.tsv",
"lineNumber": 44,
"location": " in en TIT book package from unfoldingWord master branch",
"message": "Link to TA should also be in SupportReference",
"message": "Should have a SupportReference when OccurrenceNote has a TA link",
"priority": 786,
"repoCode": "TN",
"repoName": "en_tn",
Expand All @@ -16705,7 +16722,7 @@ Object {
"filename": "en_tn_57-TIT.tsv",
"lineNumber": 91,
"location": " in en TIT book package from unfoldingWord master branch",
"message": "Link to TA should also be in SupportReference",
"message": "Should have a SupportReference when OccurrenceNote has a TA link",
"priority": 786,
"repoCode": "TN",
"repoName": "en_tn",
Expand Down
22 changes: 11 additions & 11 deletions src/__tests__/__snapshots__/tn-table-row-check.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -823,10 +823,10 @@ Object {
"C": "1",
"V": "6",
"bookID": "GEN",
"details": "detected 1 link but no TA/TW links from [\\"[[rc://*/ta/man/figs-parallelism]]\\"]",
"details": "need to carefully check [\\"[[rc://*/ta/man/figs-parallelism]]\\"]",
"fieldName": "OccurrenceNote",
"location": " that was supplied",
"message": "More [[ ]] links than valid TA/TW links",
"message": "Unusual [[ ]] link(s)—not normal TA or TW links",
"priority": 649,
"rowID": "urb3",
},
Expand All @@ -853,10 +853,10 @@ Object {
"C": "2",
"V": "12",
"bookID": "RUT",
"details": "detected 1 link but no Bible links from [\\"[[rc://*/ta/man/translate/figs-parallelism]], [Doublet](../figs-doublet/01.md)\\"]",
"details": "need to carefully check [\\"[Doublet](../figs-doublet/01.md)\\"]",
"fieldName": "OccurrenceNote",
"location": " that was supplied",
"message": "More [ ]( ) links than valid Bible links",
"message": "Unusual [ ]( ) link(s)—not normal Bible or TN links",
"priority": 648,
"rowID": "gnn5",
},
Expand Down Expand Up @@ -910,7 +910,7 @@ Object {
"extract": "figs-activepassivez",
"fieldName": "OccurrenceNote",
"location": " that was supplied",
"message": "Link to TA should also be in SupportReference",
"message": "Should have a SupportReference when OccurrenceNote has a TA link",
"priority": 786,
"rowID": "zu6f",
},
Expand All @@ -922,7 +922,7 @@ Object {
"extract": "figs-imperative",
"fieldName": "OccurrenceNote",
"location": " that was supplied",
"message": "Link to TA should also be in SupportReference",
"message": "Should have a SupportReference when OccurrenceNote has a TA link",
"priority": 786,
"rowID": "zu6f",
},
Expand All @@ -937,10 +937,10 @@ Object {
"C": "1",
"V": "7",
"bookID": "GEN",
"details": "detected 1 link but no TA/TW links from [\\"[[rc://*/ta/woman/figs-imperative]]\\"]",
"details": "need to carefully check [\\"[[rc://*/ta/woman/figs-imperative]]\\"]",
"fieldName": "OccurrenceNote",
"location": " that was supplied",
"message": "More [[ ]] links than valid TA/TW links",
"message": "Unusual [[ ]] link(s)—not normal TA or TW links",
"priority": 649,
"rowID": "urb3",
},
Expand Down Expand Up @@ -994,7 +994,7 @@ Object {
"extract": "figs-imperativez",
"fieldName": "OccurrenceNote",
"location": " that was supplied",
"message": "Link to TA should also be in SupportReference",
"message": "Should have a SupportReference when OccurrenceNote has a TA link",
"priority": 786,
"rowID": "zu6f",
},
Expand All @@ -1009,10 +1009,10 @@ Object {
"C": "1",
"V": "9",
"bookID": "GEN",
"details": "detected 1 link but no Bible links from [\\"[Genesis 1:7](../01/zzz.md)\\"]",
"details": "need to carefully check [\\"[Genesis 1:7](../01/zzz.md)\\"]",
"fieldName": "OccurrenceNote",
"location": " that was supplied",
"message": "More [ ]( ) links than valid Bible links",
"message": "Unusual [ ]( ) link(s)—not normal Bible or TN links",
"priority": 648,
"rowID": "ha33",
},
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/tn-table-row-check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import fs from 'fs-extra';
const optionalCheckingOptions = {
originalLanguageRepoUsername: 'unfoldingWord',
taRepoUsername: 'unfoldingWord',
checkLinkedTAArticleFlag: false,
checkLinkedTWArticleFlag: false,
getFile: params => {
const { username, repository, path } = params;
// console.log(`tn-table-row-check.test getFile(${username}, ${repository}, ${path})`)
Expand Down
4 changes: 2 additions & 2 deletions src/core/annotation-row-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { checkOriginalLanguageQuote } from './orig-quote-check';
import { parameterAssert } from './utilities';


// const ANNOTATION_TABLE_ROW_VALIDATOR_VERSION_STRING = '0.6.5';
// const ANNOTATION_TABLE_ROW_VALIDATOR_VERSION_STRING = '0.6.6';

const NUM_EXPECTED_ANNOTATION_TSV_FIELDS = 7; // so expects 6 tabs per line
const EXPECTED_ANNOTATION_HEADING_LINE = 'Reference\tID\tTags\tSupportReference\tQuote\tOccurrence\tAnnotation';
Expand Down Expand Up @@ -504,7 +504,7 @@ export async function checkAnnotationTSVDataRow(languageCode, annotationType, li
const adjustedLink = regexResultArray[0].substring(2, regexResultArray[0].length - 2)
if (supportReference !== adjustedLink && V !== 'intro') {
const details = supportReference ? `(SR='${supportReference}')` : "(empty SR field)"
addNoticePartial({ priority: 786, message: "Link to TA should also be in SupportReference", details, rowID, fieldName: 'Annotation', extract: adjustedLink, location: ourRowLocation });
addNoticePartial({ priority: 786, message: "Should have a SupportReference when OccurrenceNote has a TA link", details, rowID, fieldName: 'Annotation', extract: adjustedLink, location: ourRowLocation });
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/books/books.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ export const chaptersInBook = (bookId) => {
return chapters;
};

export const isOneChapterBook = (bookId) => {
return chaptersInBook(bookId).length === 1;
};

export const versesInChapter = (bookId, chapter) => {
// parameterAssert(bookId.toLowerCase() !== 'obs', `versesInChapter shouldn’t be passed '${bookId}'`);
const verses = chaptersInBook(bookId)[chapter - 1];
Expand Down
5 changes: 1 addition & 4 deletions src/core/disabled-notices.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ import { debugLog, userLog } from './utilities';
*/


// const DISABLED_NOTICES_VERSION_STRING = '0.3.1';
// const DISABLED_NOTICES_VERSION_STRING = '0.3.2';


const disabledNotices = [
// Just enter enough details to disable the required message(s) and no unwanted ones
// i.e., you can be as specific as you need about username and/or lineNumber, etc.

// TODO: Remove this -- it’s only temporary to handle valid TN links like [](../02/20/zu5f) that are checked as issues
{ repoCode: 'TN', priority: 648, }, // "More [ ]( ) links than valid Bible links" disabled as not yet properly handled by this package

{ repoCode: 'TN', priority: 450, }, // TN "Resource container link should have '*' language code with (not 'en')" disabled as tC can’t handle it yet!

{ repoCode: 'ST', message: "Bad punctuation nesting: } closing character doesn’t match", bookID: 'NEH', }, // 777 - complex { } nesting in direct speech
Expand Down
Loading