2

I'm trying to use the autosectionlabel_prefix_document config value in the autosectionlabel extension described here. I've loaded the extension in conf.py, and it works fine. Currently, I've tried adding the line:

autosectionlabel_prefix_document = True

to conf.py, but it's throwing the error message:

WARNING: undefined label: shaders:force shaders
(if the link has no caption the label must precede a section header)

Is there something I'm missing for configuring extensions? The documentation will be hosted on ReadTheDocs so I don't really have control over the extensions themselves, and it seems sloppy to have to do that anyway.

Just to be sure I have the syntax down in case that's the problem, I'm using

:ref:`shaders:force shaders`

which should be creating a link called force shaders to the subheading force shaders in the document shaders.rst.

Relevant versions:
Python 2.7
Sphinx 1.7.5
PyCharm 2018.1.4

R. Tucker
  • 21
  • 5
  • Please clarify what "but it's not working" means (error message?). I cannot reproduce any problem with this (Sphinx 1.7.5). What version of Sphinx do you use? – mzjn Jul 04 '18 at 05:47
  • Updated with relevant info – R. Tucker Jul 07 '18 at 05:08
  • @mzjn after experimenting a little bit more, it looks like the autosectionlabel_prefix_document setting is being read because the error is different than it is if I just use autosectionlabel. But that still leaves me with an error I can't figure out. Is there something wrong with my syntax in the reST itself? – R. Tucker Jul 24 '18 at 20:08
  • What's in shaders.rst? Is there a label in that document? – mzjn Jul 25 '18 at 06:12
  • @mzjn Not that was premade. You can see the doc here: https://github.com/OpenMW/openmw/blob/master/docs/source/reference/modding/settings/shaders.rst – R. Tucker Jul 25 '18 at 15:47
  • I have tried once again, but I still cannot reproduce the problem – mzjn Jul 25 '18 at 16:23
  • In your conf.py, `autosectionlabel_prefix_document = True` is commented out, but I suppose that you know that already. https://github.com/OpenMW/openmw/blob/master/docs/source/conf.py – mzjn Jul 25 '18 at 16:35
  • @mzjn Yes, I have it commented out until I can get it to work properly. Thanks for the help, I’ll try and experiment around with some fake docs to see if I can’t figure out the problem. – R. Tucker Jul 26 '18 at 17:07
  • Are you sure you are using v1.7.5 while `autosectionlabel` appear in 1.4 the option `autosectionlabel_prefix_document` is only known in v 1.6 I had the same problem using an older version. – marcz Feb 05 '19 at 15:26
  • @marcz I haven't worked on this in a while, but I do know that I was aware of the version requirement and had updated to the latest version of Sphinx. We're using RTD to host, so that's the most important, but I can't even get it to work locally, so not sure what the problem is. – R. Tucker Feb 28 '19 at 05:23

1 Answers1

1

If shaders.rst is not in the root directory, you should prefix the filename with the path from the root directory. For example, if you have the following layout:

index.rst
/xdir
    main.rst
/ydir
    /zdir
        shaders.rst

Then you can reference the heading Force Shaders located in shaders.rst from main.rst as :ref:`ydir/zdir/shaders:force shaders`. (Works with sphinx-1.7.5 for me.)

skvadrik
  • 586
  • 1
  • 3
  • 11