hynek / doc2dash

Create docsets for Dash.app-compatible API browsers.

Home Page:https://doc2dash.hynek.me/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trying to build docset for sagemath results in error

aikrahguzar opened this issue Β· comments

Hi, thanks for this tool. I have installed sagemath through nix and it includes documentation using sphinx. I am trying to build a docset for it using

doc2dash -n Sage -f -d ~/.local/share/dashdocs/ -i ~/Downloads/sage_logo_new_hc-nq8.png /nix/store/150yjwckyscc2kisgx93fs40cwk5wwdp-sagedoc-9.6/share/doc/sage/html/en/reference

However this fails with

PermissionError: [Errno 13] Permission denied: '.buildinfo'

The .buildinfo files seem to be part of many sub-directories of the documentation directory and the look like this,

# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: f164681b73cecad2fb4d00961dc5623f
tags: 645f666f9bcd5a90fca523b33c5a78b7

I assume these are for nix (I don't know much, sagemath is the only thing I use nix for). Is it possible to ignore these files somehow? Or for doc2dash to continue despite such errors and generate docset based on files it can successfully consume?

I think ignoring .buildinfo is the most straight-forward approach here.

I think ignoring .buildinfo is the most straight-forward approach here.

Agreed! Is it possible to do that? I couldn't see an option to ignore files from the output of doc2dash --help or the docs at https://doc2dash.readthedocs.io/

Would it be possible for you to try out the https://github.com/hynek/doc2dash/tree/ignore-buildinfo branch and tell me if it helped?

Would it be possible for you to try out the https://github.com/hynek/doc2dash/tree/ignore-buildinfo branch and tell me if it helped?

Hi, thank you but unfortunately it doesn't help. I don't know much python beyond what I have used for sage but here is what I tried to test the branch,

~ ❯ pipx install --spec git+https://github.com/hynek/doc2dash.git@ignore-buildinfo doc2dash
  installed package doc2dash 2.4.1.post1.dev13+g9bd1680, Python 3.10.6
  These apps are now globally available
    - doc2dash
done! ✨ 🌟 ✨

~ ❯ doc2dash -n Sage -f -d .local/share/dashdocs/ -i Downloads/sage_logo_new_hc-nq8.png /nix/store/150yjwckyscc2kisgx93fs40cwk5wwdp-sagedoc-9.6/share/doc/sage/html/en/reference
Traceback (most recent call last):
  File "/home/rahguzar/.local/bin/doc2dash", line 8, in <module>
    sys.exit(main())
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/doc2dash/__main__.py", line 178, in main
    source, dest, name = setup_paths(
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/doc2dash/__main__.py", line 285, in setup_paths
    shutil.rmtree(dest)
  File "/usr/lib64/python3.10/shutil.py", line 724, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/lib64/python3.10/shutil.py", line 657, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib64/python3.10/shutil.py", line 657, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib64/python3.10/shutil.py", line 657, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib64/python3.10/shutil.py", line 680, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/usr/lib64/python3.10/shutil.py", line 678, in _rmtree_safe_fd
    os.unlink(entry.name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: '.buildinfo'

and the error is the same as before.

Oh so the error happens when it's trying to delete something, not copy something?

Can you please give me a full trace back as returned by the current PyPI version (or the main branch)?

Oh so the error happens when it's trying to delete something, not copy something?

Can you please give me a full trace back as returned by the current PyPI version (or the main branch)?

I tried that and also started with a clean directory and this time I get a different error,

~ ❯ pipx uninstall doc2dash
uninstalled doc2dash! ✨ 🌟 ✨

~ ❯ pipx install doc2dash
  installed package doc2dash 2.4.1, Python 3.10.6
  These apps are now globally available
    - doc2dash
done! ✨ 🌟 ✨

~ ❯ doc2dash -n SageNew -d .local/share/dashdocs/ -i Downloads/sage_logo_new_hc-nq8.png /nix/store/150yjwckyscc2kisgx93fs40cwk5wwdp-sagedoc-9.6/share/doc/sage/html/en/reference
Converting intersphinx docs from "reference" to ".local/share/dashdocs/SageNew.docset".
Parsing documentation...
Added 7 index entries.
Adding table of contents meta data...  [------------------------------------------------------------------------------------------------------------------------------]    0%
Traceback (most recent call last):
  File "/home/rahguzar/.local/bin/doc2dash", line 8, in <module>
    sys.exit(main())
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/doc2dash/__main__.py", line 227, in main
    toc.close()
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/doc2dash/parsers/utils.py", line 134, in patch_anchors
    patch_files(pbar)
  File "/home/rahguzar/.local/pipx/venvs/doc2dash/lib64/python3.10/site-packages/doc2dash/parsers/utils.py", line 124, in patch_files
    with open(full_path, mode="wb") as fp:
PermissionError: [Errno 13] Permission denied: '.local/share/dashdocs/SageNew.docset/Contents/Resources/Documents/index.html'

The file in that error .local/share/dashdocs/SageNew.docset/Contents/Resources/Documents/index.html is a regular file owned by my me but its permissions are -r--r--r-- so no write permission and I think that is inherited from nix and might be the problem.

I'm starting to suspect that the issue/solution might be to change the copy mask of the files.

(I.e. make them u+rw no matter what they are before)

I'm starting to suspect that the issue/solution might be to change the copy mask of the files.

(I.e. make them u+rw no matter what they are before)

That makes sense. Is there any easy to test it?

So we can keep this open, but my suggestion to you for now is to do a cp -a NIX-PATH/docs docs; chmod -R u+w ./docs; doc2dash ... ./docs

That should fix it, no?

So we can keep this open, but my suggestion to you for now is to do a cp -a NIX-PATH/docs docs; chmod -R u+w ./docs; doc2dash ... ./docs

That should fix it, no?

Thanks a lot, that worked. I think that is an acceptable workaround for idiosyncrasies of nix so I will close this issue.