[yt-svn] commit/yt-doc: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Mar 5 10:07:03 PST 2014


2 new commits in yt-doc:

https://bitbucket.org/yt_analysis/yt-doc/commits/10aec887d87e/
Changeset:   10aec887d87e
User:        ngoldbaum
Date:        2014-01-28 07:39:43
Summary:     Updating search index hack to reflect upstream changes.
Affected #:  1 file

diff -r 157faabb091612c5dbabce2c97ffafcc93759500 -r 10aec887d87efedbfb344e85f3e828a6332fd556 source/conf.py
--- a/source/conf.py
+++ b/source/conf.py
@@ -12,23 +12,32 @@
 # serve to show the default.
 
 import sys, os, glob, re
+import sphinx
 from sphinx.search import WordCollector
 from docutils.nodes import comment, title, Text, SkipNode
+from distutils import version
+
 
 # Monkeypatching Sphinx search indexing to avoid indexing embedded
-# images, videos.
+# images, videos.  Only do this for Sphinx older than 1.2.1
 def dispatch_visit(self, node):
     if node.__class__ is comment:
         raise SkipNode
-    nodetext = re.sub(r'<img[^<]+?>', '', node.astext())
-    nodetext = re.sub(r'<video[^<]+?>', '', nodetext)
-    nodetext = re.sub(r'<(script).*?</\1>(?s)', '', nodetext)
+    # Some people might put content in raw HTML that should be searched,
+    # so we just amateurishly strip HTML tags and index the remaining
+    # content
+    nodetext = re.sub(r'(?is)<style.*?</style>', '', node.astext())
+    nodetext = re.sub(r'(?is)<script.*?</script>', '', nodetext)
+    nodetext = re.sub(r'<[^<]+?>', '', nodetext)
+    self.found_words.extend(self.lang.split(nodetext))
+    raise SkipNode
     if node.__class__ is Text:
-        self.found_words.extend(self.lang.split(nodetext))
+        self.found_words.extend(self.lang.split(node.astext()))
     elif node.__class__ is title:
-        self.found_title_words.extend(self.lang.split(nodetext))
+        self.found_title_words.extend(self.lang.split(node.astext()))
 
-WordCollector.dispatch_visit = dispatch_visit
+if version.LooseVersion(sphinx.__version__) < version.LooseVersion("1.2.1"):
+    WordCollector.dispatch_visit = dispatch_visit
 
 on_rtd = os.environ.get("READTHEDOCS", None) == "True"
 


https://bitbucket.org/yt_analysis/yt-doc/commits/d0f037569e3d/
Changeset:   d0f037569e3d
User:        MatthewTurk
Date:        2014-03-05 19:07:01
Summary:     Merged in ngoldbaum/yt-doc (pull request #143)

Updating search index monkeypatch to reflect upstream changes.
Affected #:  1 file

diff -r 4ebd1304dccab6d0d49b692848a289973e8ef818 -r d0f037569e3d1a03a41d8d4350249a5f7bad9447 source/conf.py
--- a/source/conf.py
+++ b/source/conf.py
@@ -12,23 +12,32 @@
 # serve to show the default.
 
 import sys, os, glob, re
+import sphinx
 from sphinx.search import WordCollector
 from docutils.nodes import comment, title, Text, SkipNode
+from distutils import version
+
 
 # Monkeypatching Sphinx search indexing to avoid indexing embedded
-# images, videos.
+# images, videos.  Only do this for Sphinx older than 1.2.1
 def dispatch_visit(self, node):
     if node.__class__ is comment:
         raise SkipNode
-    nodetext = re.sub(r'<img[^<]+?>', '', node.astext())
-    nodetext = re.sub(r'<video[^<]+?>', '', nodetext)
-    nodetext = re.sub(r'<(script).*?</\1>(?s)', '', nodetext)
+    # Some people might put content in raw HTML that should be searched,
+    # so we just amateurishly strip HTML tags and index the remaining
+    # content
+    nodetext = re.sub(r'(?is)<style.*?</style>', '', node.astext())
+    nodetext = re.sub(r'(?is)<script.*?</script>', '', nodetext)
+    nodetext = re.sub(r'<[^<]+?>', '', nodetext)
+    self.found_words.extend(self.lang.split(nodetext))
+    raise SkipNode
     if node.__class__ is Text:
-        self.found_words.extend(self.lang.split(nodetext))
+        self.found_words.extend(self.lang.split(node.astext()))
     elif node.__class__ is title:
-        self.found_title_words.extend(self.lang.split(nodetext))
+        self.found_title_words.extend(self.lang.split(node.astext()))
 
-WordCollector.dispatch_visit = dispatch_visit
+if version.LooseVersion(sphinx.__version__) < version.LooseVersion("1.2.1"):
+    WordCollector.dispatch_visit = dispatch_visit
 
 on_rtd = os.environ.get("READTHEDOCS", None) == "True"

Repository URL: https://bitbucket.org/yt_analysis/yt-doc/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list