Skip to content

Commit 059a74c

Browse files
committed
Fix #1784: Provide non-minified JS code in sphinx/search/*.py
1 parent a9afcb8 commit 059a74c

33 files changed

+42833
-0
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Bugs fixed
1717
* #1823: '.' as <module_path> for sphinx-apidoc cause an unfriendly error. Now '.'
1818
is converted to absolute path automatically.
1919
* Fix a crash when setting up extensions which do not support metadata.
20+
* #1784: Provide non-minified JS code in sphinx/search/*.py
2021

2122

2223
Release 1.3.1 (released Mar 17, 2015)

sphinx/builders/html.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,12 @@ def copy_static_files(self):
584584
copyfile(jsfile, path.join(self.outdir, '_static',
585585
'translations.js'))
586586

587+
# copy non-minified stemmer JavaScript file
588+
if self.indexer is not None:
589+
jsfile = self.indexer.get_js_stemmer_rawcode()
590+
if jsfile:
591+
copyfile(jsfile, path.join(self.outdir, '_static', '_stemmer.js'))
592+
587593
ctx = self.globalcontext.copy()
588594

589595
# add context items for search function used in searchtools.js_t

sphinx/search/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from six import iteritems, itervalues, text_type, string_types
1414
from six.moves import cPickle as pickle
1515
from docutils.nodes import raw, comment, title, Text, NodeVisitor, SkipNode
16+
from os import path
1617

1718
from sphinx.util import jsdump, rpartition
1819

@@ -42,6 +43,7 @@ class SearchLanguage(object):
4243
lang = None
4344
language_name = None
4445
stopwords = set()
46+
js_stemmer_rawcode = None
4547
js_stemmer_code = """
4648
/**
4749
* Dummy stemmer for languages without stemming rules.
@@ -377,3 +379,11 @@ def context_for_searchtool(self):
377379
search_language_stop_words = jsdump.dumps(sorted(self.lang.stopwords)),
378380
search_scorer_tool = self.js_scorer_code,
379381
)
382+
383+
def get_js_stemmer_rawcode(self):
384+
if self.lang.js_stemmer_rawcode:
385+
return path.join(
386+
path.dirname(path.abspath(__file__)),
387+
'non-minified-js',
388+
self.lang.js_stemmer_rawcode
389+
)

sphinx/search/da.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
class SearchDanish(SearchLanguage):
121121
lang = 'da'
122122
language_name = 'Danish'
123+
js_stemmer_rawcode = 'danish-stemmer.js'
123124
js_stemmer_code = js_stemmer
124125
stopwords = danish_stopwords
125126

sphinx/search/de.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@
303303
class SearchGerman(SearchLanguage):
304304
lang = 'de'
305305
language_name = 'German'
306+
js_stemmer_rawcode = 'german-stemmer.js'
306307
js_stemmer_code = js_stemmer
307308
stopwords = german_stopwords
308309

sphinx/search/es.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
class SearchSpanish(SearchLanguage):
364364
lang = 'es'
365365
language_name = 'Spanish'
366+
js_stemmer_rawcode = 'spanish-stemmer.js'
366367
js_stemmer_code = js_stemmer
367368
stopwords = spanish_stopwords
368369

sphinx/search/fi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
class SearchFinnish(SearchLanguage):
114114
lang = 'fi'
115115
language_name = 'Finnish'
116+
js_stemmer_rawcode = 'finnish-stemmer.js'
116117
js_stemmer_code = js_stemmer
117118
stopwords = finnish_stopwords
118119

sphinx/search/fr.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
class SearchFrench(SearchLanguage):
200200
lang = 'fr'
201201
language_name = 'French'
202+
js_stemmer_rawcode = 'french-stemmer.js'
202203
js_stemmer_code = js_stemmer
203204
stopwords = french_stopwords
204205

sphinx/search/hu.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
class SearchHungarian(SearchLanguage):
228228
lang = 'hu'
229229
language_name = 'Hungarian'
230+
js_stemmer_rawcode = 'hungarian-stemmer.js'
230231
js_stemmer_code = js_stemmer
231232
stopwords = hungarian_stopwords
232233

sphinx/search/it.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@
316316
class SearchItalian(SearchLanguage):
317317
lang = 'it'
318318
language_name = 'Italian'
319+
js_stemmer_rawcode = 'italian-stemmer.js'
319320
js_stemmer_code = js_stemmer
320321
stopwords = italian_stopwords
321322

sphinx/search/nl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
class SearchDutch(SearchLanguage):
121121
lang = 'nl'
122122
language_name = 'Dutch'
123+
js_stemmer_rawcode = 'dutch-stemmer.js'
123124
js_stemmer_code = js_stemmer
124125
stopwords = danish_stopwords
125126

sphinx/search/no.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
class SearchNorwegian(SearchLanguage):
203203
lang = 'no'
204204
language_name = 'Norwegian'
205+
js_stemmer_rawcode = 'norwegian-stemmer.js'
205206
js_stemmer_code = js_stemmer
206207
stopwords = norwegian_stopwords
207208

0 commit comments

Comments
 (0)