You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -121,6 +121,10 @@ Check a library to ensure they have the correct structure. This will also run `c
121
121
Check [library.properties](https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format) metadata files for errors.
122
122
- Parameter: **searchPath** - Path containing library.properties files. The path will be searched recursively and all library.properties files found under it will be checked.
123
123
124
+
##### `check_keywords_txt searchPath'
125
+
Check [keywords.txt](https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#keywords) files for errors.
126
+
- Parameter: **searchPath** - Path containing keywords.txt files. The path will be searched recursively and all keywords.txt files found under it will be checked.
echo"ERROR: $keywordsTxtPath uses invalid field separator. It must be a true tab."
1620
+
return 3
1621
+
fi
1622
+
1623
+
# Check for multiple tabs used as separator where this causes unintended results
1624
+
local consequentialMultipleSeparatorRegex='^[[:space:]]*[^[:space:]]+[[:space:]]*'$'\t\t''+((KEYWORD1)|(LITERAL1))'
1625
+
if [[ "$keywordsTxtLine"=~$consequentialMultipleSeparatorRegex ]];then
1626
+
echo"ERROR: $keywordsTxtPath uses multiple tabs as field separator. It must be a single tab. This causes the default keyword coloring (as used by KEYWORD2, KEYWORD3, LITERAL2) to be used rather than the intended coloration."
1627
+
return 4
1628
+
fi
1629
+
1630
+
# Get the field values
1631
+
# Use a unique, non-whitespace field separator character
1632
+
fieldSeparator=$'\a'
1633
+
IFS=$fieldSeparator
1634
+
# Change tabs to the field separator character for line splitting
1635
+
local keywordsTxtLineSwappedTabs=(${keywordsTxtLine//$'\t'/$fieldSeparator})
1636
+
1637
+
# Unused, so commented
1638
+
# # KEYWORD is the 1st field
1639
+
# local keywordRaw=${keywordsTxtLineSwappedTabs[0]}
1640
+
# # The Arduino IDE strips leading whitespace and trailing spaces from KEYWORD
1641
+
# # Strip leading whitespace
1642
+
# local keywordFrontStripped="${keywordRaw#"${keywordRaw%%[![:space:]]*}"}"
1643
+
# # Strip trailing spaces
1644
+
# local keyword="${keywordFrontStripped%"${keywordFrontStripped##*[! ]}"}"
1645
+
1646
+
# KEYWORD_TOKENTYPE is the 2nd field
1647
+
local keywordTokentypeRaw=${keywordsTxtLineSwappedTabs[1]}
1648
+
# The Arduino IDE strips trailing spaces from KEYWORD_TOKENTYPE
1649
+
# Strip trailing spaces
1650
+
local keywordTokentype="${keywordTokentypeRaw%"${keywordTokentypeRaw##*[! ]}"}"
1651
+
1652
+
# REFERENCE_LINK is the 3rd field
1653
+
local referenceLinkRaw=${keywordsTxtLineSwappedTabs[2]}
1654
+
# The Arduino IDE strips leading and trailing whitespace from REFERENCE_LINK
1655
+
# Strip leading spaces
1656
+
local referenceLinkFrontStripped="${referenceLinkRaw#"${referenceLinkRaw%%[! ]*}"}"
1657
+
# Strip trailing spaces
1658
+
local referenceLink="${referenceLinkFrontStripped%"${referenceLinkFrontStripped##*[! ]}"}"
1659
+
1660
+
# RSYNTAXTEXTAREA_TOKENTYPE is the 4th field
1661
+
local rsyntaxtextareaTokentypeRaw=${keywordsTxtLineSwappedTabs[3]}
1662
+
# The Arduino IDE strips trailing spaces from RSYNTAXTEXTAREA_TOKENTYPE
1663
+
# Strip trailing spaces
1664
+
local rsyntaxtextareaTokentype="${rsyntaxtextareaTokentypeRaw%"${rsyntaxtextareaTokentypeRaw##*[! ]}"}"
1665
+
1666
+
# Reset IFS to default
1667
+
unset IFS
1668
+
1669
+
# Check for multiple tabs used as separator where this causes no unintended results
1670
+
# A large percentage of Arduino libraries have this problem
1671
+
local inconsequentialMultipleSeparatorRegex='^[[:space:]]*[^[:space:]]+[[:space:]]*'$'\t\t''+((KEYWORD2)|(KEYWORD3)|(LITERAL2))'
1672
+
if [[ "$keywordsTxtLine"=~$inconsequentialMultipleSeparatorRegex ]];then
1673
+
echo"WARNING: $keywordsTxtPath uses multiple tabs as field separator. It must be a single tab. This causes the default keyword coloring (as used by KEYWORD2, KEYWORD3, LITERAL2). In this case that doesn't cause the keywords to be incorrectly colored as expected but it's recommended to fully comply with the Arduino library specification."
1674
+
else
1675
+
# The rest of the checks will be borked by the use of multiple tabs as a separator
1676
+
1677
+
# Check for invalid KEYWORD_TOKENTYPE
1678
+
local validKeywordTokentypeRegex='^((KEYWORD1)|(KEYWORD2)|(KEYWORD3)|(LITERAL1)|(LITERAL2))$'
echo"ERROR: $keywordsTxtPath uses invalid KEYWORD_TOKENTYPE: ${keywordTokentype}, which causes the default keyword coloration to be used. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#keyword_tokentype"
1681
+
return 5
1682
+
fi
1683
+
1684
+
# Check for invalid RSYNTAXTEXTAREA_TOKENTYPE
1685
+
if [[ "$rsyntaxtextareaTokentype"!="" ]];then
1686
+
local validRsyntaxtextareaTokentypeRegex='^((RESERVED_WORD)|(RESERVED_WORD2)|(DATA_TYPE)|(PREPROCESSOR))$'
echo"ERROR: $keywordsTxtPath uses invalid RSYNTAXTEXTAREA_TOKENTYPE: ${rsyntaxtextareaTokentype}, which causes the default keyword coloration to be used. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#rsyntaxtextarea_tokentype"
1689
+
return 6
1690
+
fi
1691
+
fi
1692
+
1693
+
# Check for invalid REFERENCE_LINK
1694
+
if [[ "$referenceLink"!="" ]];then
1695
+
# The Arduino IDE must be installed to check if the reference page exists
1696
+
if [[ "$NEWEST_INSTALLED_IDE_VERSION"=="" ]];then
1697
+
echo"WARNING: Arduino IDE is not installed so unable to check for invalid reference links. Please call install_ide before running check_keywords_txt."
echo"ERROR: $keywordsTxtPath uses a REFERENCE_LINK value: $referenceLink that is not a valid Arduino Language Reference page. See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#reference_link"
1702
+
return 7
1703
+
fi
1704
+
fi
1705
+
fi
1706
+
1707
+
fi
1708
+
fi
1709
+
done<<<"$keywordsTxtCRline"
1710
+
done<"$keywordsTxtPath"
1711
+
done
1712
+
}
1713
+
1714
+
1582
1715
# Set default verbosity (must be called after the function definitions
0 commit comments