sphinx-contrib / sphinx-pretty-searchresults

Sphinx: pretty search results is an extension for the Sphinx documentation tool. To display search results, Sphinx is fetching the source files of search hits and rendering excerpts in raw markup. This extension removes the markup from these source files (during build time), so the search results look decent.
https://pypi.python.org/pypi/sphinxprettysearchresults
MIT License
22 stars 5 forks source link

cannot concatenate 'str' and 'NoneType' objects #1

Open pybride opened 8 years ago

pybride commented 8 years ago

Hi,

Thanks for this extension, it is what we need. Unfortunately, it isn't working:

sphinx-err-rmic8m.log.txt

I tried to remove '-D' 'language=' + language as I don't need I18N, but then I get:

sphinx-err-3cju9l.log.txt

Best regards, Pierre-Yann

TimKam commented 8 years ago

Thanks for your report. Might be an issue that just occurs on Windows. It would be great if you could verify/falsify this assumption.

In any case, I'll have a look later today.

TimKam commented 8 years ago

I was wrong with my assumption. There were two issues: 1) The build failed if you didn't specify a language in the config file. 2) The build assumed . is the source directory and failed if this wasn't true.

Can you confirm that it works now for you, @pybride ?

pybride commented 8 years ago

As I'm using a French Windows today, I have now another issue:

Exception occurred: File "c:\python27\lib\subprocess.py", line 958, in _execute_child startupinfo) WindowsError: [Error 2] Le fichier spÚcifiÚ est introuvable Traceback (most recent call last): File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main "main", fname, loader, pkg_name) File "c:\python27\lib\runpy.py", line 72, in _run_code exec code in run_globals File "c:\Python27\Scripts\sphinx-build.exemain.py", line 9, in File "c:\python27\lib\site-packages\sphinxinit.py", line 51, in main sys.exit(build_main(argv)) File "c:\python27\lib\site-packages\sphinxinit.py", line 92, in build_main return cmdline.main(argv) File "c:\python27\lib\site-packages\sphinx\cmdline.py", line 284, in main tbpath = save_traceback(app) File "c:\python27\lib\site-packages\sphinx\utilinit.py", line 255, in save_traceback os.write(fd, exc_format.encode('utf-8')) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 920: ordinal not in range(128)

It seems a common problem with Popen on Windows, but I don't even know which string is creating the issue. I printed some variables: ('project_path', 'c:\python27\lib\site-packages') ('srcdir', u'd:\Projects\Platypus\Main\Doc\Sphinx') ('sources_build_path', '../_build_txt')

TimKam commented 8 years ago

For a quick fix, you can try adding these line below line 41 of __init__.py:

if isinstance(srcdir, unicode):
    srcdir = srcdir.encode('UTF-8')

I'll see if I can reproduce your issue on a Windows machine later.

pybride commented 8 years ago

It doesn't resolve the issue.

TimKam commented 8 years ago

I could reproduce the issue on a Windows machine and fix it (for me). Can you confirm, @pybride ?

pybride commented 8 years ago

I'm using a English Windows today, therefore I don't expect the same issues. But it is still not working. First, I don't get the 1.3 version (pip install sphinxprettysearchresults --upgrade give me 1.2) Then, I have now "The system cannot find the file specified", even when copying manually version 1.3

sphinx-err-njbgj6.log.txt

Some print out: ('srcdir', 'd:\Projects\Platypus\Main\Doc\Sphinx') ('sources_build_path', '../_build_txt')

I got the _build_txt folder, but a level above my sphinx data and make.bat. Shouldn't it be on the same level as _build? I change to sources_build_path = '_build_txt', but I don't have more success.

TimKam commented 8 years ago

The current version on PyPi is 0.1.3, so I can't understand why it doesn't do the update for you. I'll try to reproduce the 2nd issue asap.

TimKam commented 8 years ago

@pybride :

I couldn't reproduce these issues on my Windows machine. Could you check which of the directories doesn't exist?

You can add the following line before the build_txt = ... line:

 print 'isdir sources_build_path: ' + os.path.isdir(sources_build_path)
 print 'isdir srcdir: ' + os.path.isdir(srcdir)

The exact sphinx-build command you use might also be relevant.

I changed the sources build path to _build_txt(removed the ../), but did not release this, yet.

pybride commented 8 years ago

Finally, I could run it, but only with:

build_txt = subprocess.Popen(['c:\Python27\Scripts\sphinx-build', '-a', '-b', 'text','-D' 'language=' + language, srcdir, sources_build_path])

I need the full path to sphinx-build.

TimKam commented 8 years ago

Thanks for the info, I'll work on a fix

pybride commented 8 years ago

Maybe the issue is related to how we install Python. As we only use it for sphinx, Python.exe isn't put in the PATH, therefore, for example, pip only work from c:\Python27\Scripts (or if the full path is used).

Also, the make.bat created by sphinx has these lines: if "%SPHINXBUILD%" == "" ( set SPHINXBUILD="c:\Python27\Scripts\sphinx-build" )

TimKam commented 7 years ago

Because I can't reproduce any related errors, I'll close this issue. Please ask me to re-open if you still experience problems.

pybride commented 7 years ago

We updated to 0.3.1, but we still need to change the Popen line to make it work. And it happens on several machines (Windows 10 Pro/Enterprise English)

build_txt = subprocess.Popen(['c:\Python27\Scripts\sphinx-build', '-a', '-b', 'text','-D' 'language=' + language, srcdir, sources_build_path])

TimKam commented 7 years ago

Is your project OS or can you provide a minimal working example that allows me to reproduce this issue?

pybride commented 7 years ago

Not open source. As we are now working on the release, I will try to create a working example in the next few days.

TimKam commented 7 years ago

Thanks, I'll have a look then

pybride commented 7 years ago

Here is a very simple project, which also has the issue on make html. I also put the log file in it.

sphinx-pretty-searchresults bug on windows.zip