From 44978b744d860abd7f27216a1b7d92f04c28c945 Mon Sep 17 00:00:00 2001 From: Kevin Putnam Date: Tue, 18 Dec 2018 11:37:46 -0800 Subject: [PATCH 1/4] added whitelist and parse script. changed Makefile --- source/Makefile | 5 +- source/scripts/_python/link-whitelist.txt | 19 ++++++ source/scripts/_python/parse-link-check.py | 67 ++++++++++++++++++++++ 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 source/scripts/_python/link-whitelist.txt create mode 100644 source/scripts/_python/parse-link-check.py diff --git a/source/Makefile b/source/Makefile index 655286aa..d9025515 100644 --- a/source/Makefile +++ b/source/Makefile @@ -166,10 +166,9 @@ changes: @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + -$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + python3 scripts/_python/parse-link-check.py $(BUILDDIR)/linkcheck @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest diff --git a/source/scripts/_python/link-whitelist.txt b/source/scripts/_python/link-whitelist.txt new file mode 100644 index 00000000..a33863a4 --- /dev/null +++ b/source/scripts/_python/link-whitelist.txt @@ -0,0 +1,19 @@ +http://www.intel.com/content/www/us/en/virtualization/virtualization-technology/intel-virtualization-technology.html +https://software.intel.com/en-us/articles/intel-virtualization-technology-for-directed-io-vt-d-enhancing-intel-platforms-for-efficient-virtualization-of-io-devices +http://www.intel.com/content/www/us/en/virtualization/virtualization-technology/intel-virtualization-technology.html +https://software.intel.com/en-us/articles/intel-virtualization-technology-for-directed-io-vt-d-enhancing-intel-platforms-for-efficient-virtualization-of-io-devices +https://software.intel.com/en-us/articles/intel-virtualization-technology-for-directed-io-vt-d-enhancing-intel-platforms-for-efficient-virtualization-of-io-devices +https://www.intel.com/content/www/us/en/virtualization/virtualization-technology/intel-virtualization-technology.html +https://www.intel.com/content/www/us/en/virtualization/virtualization-technology/intel-virtualization-technology.html +https://github.com/clearlinux/common#build-rpms-for-a-package +https://www.intel.com/content/www/us/en/privacy/intel-privacy-notice.html +http://ark.intel.com +https://clearlinux.org/documentation/clear-linux/concepts/bundles-about#related-concepts +https://software.intel.com/en-us/articles/OpenVINO-ModelOptimizer +https://github.com/kata-containers/documentation/blob/master/Upgrading.md#maintenance-warning +https://github.com/clearcontainers/runtime#configuration +https://github.com/kata-containers/runtime#configuration +https://kubernetes.io/docs/user-journeys/users/application-developer/foundational/#section-3 +https://kubernetes.io/docs/user-journeys/users/application-developer/foundational/#section-2 +https://www.intel.com/content/www/us/en/privacy/intel-privacy-notice.html +http://www.intel.com/content/www/us/en/nuc/nuc-kit-nuc6i5syh.html \ No newline at end of file diff --git a/source/scripts/_python/parse-link-check.py b/source/scripts/_python/parse-link-check.py new file mode 100644 index 00000000..7aaa9f69 --- /dev/null +++ b/source/scripts/_python/parse-link-check.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +import sys +import re +import os + +fileName = "output.txt" +outFile = "broken_links.html" +whitelistFile = "link-whitelist.txt" + +if len(sys.argv) < 2: + print ("Enter path of input directory") + sys.exit() + +scriptPath = sys.argv[0] +outputPath = sys.argv[1] +fileNamePath = outputPath + "/" + fileName +outFilePath = outputPath + "/" + outFile + +whitelistFilePath = os.path.dirname(scriptPath) + "/" + whitelistFile + +with open (whitelistFilePath) as w: + whLines = w.readlines() + +whitelist = [] +for line in whLines: + link = line.rstrip() + whitelist.append(link) + +with open (fileNamePath) as f: + lines = f.readlines() + +numBrokenLinks = 0 +numWhiteListMatches = 0 +newLines = [""] +whiteListLines = [] + +for line in lines: + if "[broken]" in line: + strings = line.split(" ") + link = strings[2][:-1] + link = link.strip() + if link in whitelist: + whiteListLines.append("" + strings[0] + "\n
[whitelist] " + link + "
\n") + numWhiteListMatches += 1 + else: + newLines.append("" + strings[0] + "\n
[broken] " + link + "
\n") + numBrokenLinks += 1 + +newLines.insert(0,"

" + str(numBrokenLinks + numWhiteListMatches) + " broken links found in Sphinx link check

\n") +newLines.insert(1,"

" + str(numBrokenLinks) + " unmatched broken links

\n") +newLines.append("

" + str(numWhiteListMatches) + " links matched whitelist

\n") +for line in whiteListLines: + newLines.append(line) +newLines.append("") + +with open (outFilePath, "w") as outF: + for line in newLines: + outF.write(line) + +print("See ./" + outFilePath + " for a detailed breakdown of broken links.") + +if numBrokenLinks != 0: + print (numBrokenLinks + " detected. Exiting with error code 255.") + sys.exit(-1) +else: + print ("No unexpected broken links detected.") From 4a3b3743673d8105c2327af63fb24be1665b6fc2 Mon Sep 17 00:00:00 2001 From: Kevin Putnam Date: Tue, 18 Dec 2018 11:56:15 -0800 Subject: [PATCH 2/4] added documentation comments to parse-link-check.py --- source/scripts/_python/parse-link-check.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/scripts/_python/parse-link-check.py b/source/scripts/_python/parse-link-check.py index 7aaa9f69..9909cf1d 100644 --- a/source/scripts/_python/parse-link-check.py +++ b/source/scripts/_python/parse-link-check.py @@ -1,5 +1,25 @@ #!/usr/bin/env python +#*********************************************************** +# +# parse-link-check.py +# +# Arguments: +# 1. path to input file +# +# External file dependencies: +# 1. output.txt - the output of sphinx-build +# 2. link-whitelist.txt - broken links that should be ignored +# +# Output: +# 1. broken_links.html - provides count of broken and whitelist +# matches. Also provides links to all flagged links. Will +# appear in the same directory as output.txt +# 2. Error code 255 if unexpected broken links are found +# +#*********************************************************** + + import sys import re import os From a80b1f5727423e05399d46d45cf855484680883a Mon Sep 17 00:00:00 2001 From: Kevin Putnam Date: Wed, 26 Dec 2018 11:52:31 -0800 Subject: [PATCH 3/4] removed unnecessary @echo in Makefile --- source/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/source/Makefile b/source/Makefile index d9025515..47c4ff1a 100644 --- a/source/Makefile +++ b/source/Makefile @@ -168,7 +168,6 @@ changes: linkcheck: -$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck python3 scripts/_python/parse-link-check.py $(BUILDDIR)/linkcheck - @echo doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest From a3c1c5b9c3647d7801c7ea604fb9a259efe8a6a0 Mon Sep 17 00:00:00 2001 From: Kevin Putnam Date: Fri, 28 Dec 2018 10:02:54 -0800 Subject: [PATCH 4/4] moved linkcheck helper script to sub-directory --- source/Makefile | 2 +- source/scripts/_python/{ => linkcheck}/link-whitelist.txt | 0 source/scripts/_python/{ => linkcheck}/parse-link-check.py | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename source/scripts/_python/{ => linkcheck}/link-whitelist.txt (100%) rename source/scripts/_python/{ => linkcheck}/parse-link-check.py (100%) diff --git a/source/Makefile b/source/Makefile index 47c4ff1a..6ef592c3 100644 --- a/source/Makefile +++ b/source/Makefile @@ -167,7 +167,7 @@ changes: linkcheck: -$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - python3 scripts/_python/parse-link-check.py $(BUILDDIR)/linkcheck + python3 scripts/_python/linkcheck/parse-link-check.py $(BUILDDIR)/linkcheck doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest diff --git a/source/scripts/_python/link-whitelist.txt b/source/scripts/_python/linkcheck/link-whitelist.txt similarity index 100% rename from source/scripts/_python/link-whitelist.txt rename to source/scripts/_python/linkcheck/link-whitelist.txt diff --git a/source/scripts/_python/parse-link-check.py b/source/scripts/_python/linkcheck/parse-link-check.py similarity index 100% rename from source/scripts/_python/parse-link-check.py rename to source/scripts/_python/linkcheck/parse-link-check.py