rstcheck / rstcheck-core

Core library behind rstcheck.
http://rstcheck-core.rtfd.io/
MIT License
4 stars 8 forks source link

[Bug]: AttributeError when using `.. include::` #95

Closed htgoebel closed 7 months ago

htgoebel commented 8 months ago

To Dos

Example Code (rst)

This is the outer text.

.. include:: _common_definitions.txt

Relevant log output

WARNING:rstcheck_core.checker:An `AttributeError` error occured. 
This is most probably due to a code block directive (code/code-block/sourcecode)
without a specified language. This may result in a false negative for source: 'index.rst'.
The reason can also be another directive. For more information see the FAQ 
(https://rstcheck-core.rtfd.io/en/latest/faq) or the corresponding 
github issue: https://github.com/rstcheck/rstcheck-core/issues/3.

Description

The file above is named index.rst. There is a second file (_common_definitions.txt):

This is some included text.

Additionally:

Operating System

Linux

Operating System Details

No response

Python Version

3.10

rstcheck Version

rstcheck CLI Version: 6.2.0 rstcheck-core Version: 1.2.0

Additional Context

No response

Cielquan commented 7 months ago

The issue is independent of the CLI so I moved the issue here.

The AttributeError is caused inside sphinx internal code. https://github.com/rstcheck/rstcheck-core/issues/3#issuecomment-1681934867 mentioned that this error can be caused from include directives, but it mostly occurs with language-less code-blocks as far as I know. Unfortunately this issue is almost a decade old (https://github.com/rstcheck/rstcheck-core/issues/3#issuecomment-1140405059) and I don't have a fix for this. But I am open for PRs if you find a fix.

What wonders me in your case is, that you seem to use rst2html5 and not sphinx for building you docs. The issue only occurs if sphinx is installed inside the venv from where you are running rstcheck. And when you install rstcheck it only installs sphinx too if you run something like pip install rstcheck[sphinx]. Therefore it could be a simple fix to remove sphinx if you do not use it.

Closing as duplicate/in favor of #3.

htgoebel commented 7 months ago

Sorry, I missed that #3 also mentions include directives.

I'm using sphinx for building the docs. Above I just used rst2html5 to show/test that index.rst compiles fine when using just rst2x.

When not installing sphinx in the environment I get lots of "Unknown interpreted text role" and "Unknown directive type" errors. Thus this seems to not be the solution either :-/

Cielquan commented 7 months ago

Ah ok. Yeah all those unknown things are then probably sphinx things which are not part of basic RST.