Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong content type of a dotx template #41

Open
Lennonka opened this issue Apr 4, 2021 · 2 comments
Open

Wrong content type of a dotx template #41

Lennonka opened this issue Apr 4, 2021 · 2 comments

Comments

@Lennonka
Copy link

Lennonka commented Apr 4, 2021

Sphinx output:

Exception occurred:
  File "/usr/local/lib/python3.8/dist-packages/docx/api.py", line 28, in Document
    raise ValueError(tmpl % (docx, document_part.content_type))
ValueError: file 'source/internal-long-style.dotx' is not a Word file,
content type is 'application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml'

What is the correct content type? My dotx file is a direct export from MS Word. Are there any limitations to versions of MS Word? Or to cloud/desktop variants of MS Office?

Error log:

# Sphinx version: 3.5.1
# Python version: 3.8.5 (CPython)
# Docutils version: 0.15 release
# Jinja2 version: 2.11.3
# Last messages:
#   reading sources... [ 66%] 01 Decision Record
#   reading sources... [100%] index
#   
#   looking for now-outdated files...
#   none found
#   pickling environment...
#   done
#   checking consistency...
#   done
#   preparing documents...
# Loaded extensions:
#   sphinx.ext.mathjax (3.5.1) from /usr/local/lib/python3.8/dist-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /usr/local/lib/python3.8/dist-packages/sphinxcontrib/applehelp/>
#   sphinxcontrib.devhelp (1.0.2) from /usr/local/lib/python3.8/dist-packages/sphinxcontrib/devhelp/__in>
#   sphinxcontrib.htmlhelp (1.0.3) from /usr/local/lib/python3.8/dist-packages/sphinxcontrib/htmlhelp/__>
#   sphinxcontrib.serializinghtml (1.1.4) from /usr/local/lib/python3.8/dist-packages/sphinxcontrib/seri>
#   sphinxcontrib.qthelp (1.0.3) from /usr/local/lib/python3.8/dist-packages/sphinxcontrib/qthelp/__init>
#   alabaster (0.7.12) from /usr/local/lib/python3.8/dist-packages/alabaster/__init__.py
#   sphinx.ext.todo (3.5.1) from /usr/local/lib/python3.8/dist-packages/sphinx/ext/todo.py
#   docxsphinx (unknown version) from /usr/local/lib/python3.8/dist-packages/docxsphinx/__init__.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/sphinx/cmd/build.py", line 280, in build_main
    app.build(args.force_all, filenames)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/application.py", line 352, in build
    self.builder.build_update()
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/__init__.py", line 293, in build_update
    self.build(['__all__'], to_build)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/__init__.py", line 360, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/local/lib/python3.8/dist-packages/docxsphinx/builder.py", line 77, in write
    self.prepare_writing(docnames)
  File "/usr/local/lib/python3.8/dist-packages/docxsphinx/builder.py", line 62, in prepare_writing
    self.writer = DocxWriter(self)
  File "/usr/local/lib/python3.8/dist-packages/docxsphinx/writer.py", line 83, in __init__
    dc = Document(os.path.join('source', self.template_dir))
  File "/usr/local/lib/python3.8/dist-packages/docx/api.py", line 28, in Document
    raise ValueError(tmpl % (docx, document_part.content_type))
ValueError: file 'source/internal-long-style.dotx' is not a Word file,
content type is 'application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml'
@hugobuddel
Copy link
Collaborator

The 'template' is actually an empty word document, a docx, so not a true template. We should document this better (see also #39 ) and perhaps indeed use a proper dotx template file.

@Lennonka
Copy link
Author

Lennonka commented Apr 7, 2021

Thanks for the info!
By the way, I can help with the docs (as a volunteer), I'll be available in June as I have too many projects on my plate right now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants