How to create a link to external file section with Sphinx? - python-sphinx

I want to create a link that refers to a section defined in another file.
I have found a similar question on "Python-Sphinx: Link to Section in external File" and I noticed there is an extension called "intersphinx".
So I tried this extension, but it doesn't work (Probably my usage is wrong).
I have tried the following.
conf.py
extensions = ['sphinx.ext.todo', 'sphinx.ext.intersphinx']
...
intersphinx_mapping = {'myproject': ('../build/html', None)}
foo.rst
...
****************
Install Bar
****************
Please refer :ref:`Bar Installation Instruction<myproject:bar_installation>`
I want to create a link like 'Bar Installation Instruction' with above markup.
bar.rst
...
**************************
Installation Instruction
**************************
.. _bar_installation:
some text...
When I run make html, I get the following warning and the link is not created.
foo.rst: WARNING: undefined label: myproject:bar_installation (if the link has no caption the label must precede a section header)
Thanks in advance.

Looks like it's not able to find your mapping inventory file. The first part of the tuple serves as the base URL for your links while the second part is the path to the inventory file. I believe the auto downloading of the inventory files (when you pass None) only works with URIs and not file paths.
In this example, I can build the documentation locally, but it will link to http://example.com/docs/bar.html
'myproject': (
'http://example.com/docs/',
'../html/objects.inv'
)

Related

module files not downloading for themes

I want to change my site using Hugo. I get stuck with modules. As per documentation (e.g. this theme) I just add theme = "github.com/nodejh/hugo-theme-mini" to the config file. It fails like this:
WARN ... found no layout file for "HTML" for kind "term": You should ...
if I perform hugo mod vendor the directory structure of the theme seems created in the _vendor dir, but there is not a single file inside. which explains the "not found" error in my eyes.
nothing (!) is rendered.
I also have this effect with a couple of other themes (I thinknoteworthy being one of them).
Set up a clean project
hugo new site testModules
cd testModules
and enable Hugo modules
hugo mod init randomName`
Paste the following lines in config.toml:
baseURL = "http://example.org/"
title = "Hugo Modules Test"
[module]
[[module.imports]]
path = "github.com/nodejh/hugo-theme-mini"
Start Hugo
hugo serve -D
Done!
The content of github.com/nodejh/hugo-theme-mini" will be downloaded and used as theme.
See the theme's documentation to add content
Optional:
hugo mod vendor
will make the content of the remote repo available in the _vendor folder.
(Surprisingly the content of exampleSite was not downloaded during the quick test I made)

Inno Setup: Load file edited during installation for wpInfoAfter

I would like to use wpInfoAfter page in my installation to display a summary of my installation with Inno Setup. And I would like to load a file that is edited during the [Run] section and during the ssInstall step.
In the documentation they say that is should be located to be loaded by the compiler, and me I would like to load it after install.
How can I do that ? Thanks.
Use a dummy file for the InfoAfterFile directive (just to activate the page).
And then on runtime, load the file you want:
WizardForm.InfoAfterMemo.Lines.LoadFromFile(FileName);

restructuredtext link to other rst file menu anchor

With this structure:
$ tree
.
├── Editors.rst
└── Tool_vim.rst
From Editor.rst file I want to do a link to the Tool_vim.rst file.
I get it with:
Follow install from :doc:`Tool_linux_install`
But on Tool_linux_install.rst I have a menu with .. contents:: and sections but I don't succeed to do a link to the vim chapter:
Follow install from :doc:`Tool_linux_install#vim`
But I get an error when compiling:
Tool_vim.rst:423: WARNING: unknown document: Tool_linux_install#vim
The :doc: role can be used to link to another document, but it does not support linking to a specific location within the document.
Instead, use the :ref: role to link to a target defined by a label. It is possible to generate labels automatically with the sphinx.ext.autosectionlabel extension.
See also https://github.com/sphinx-doc/sphinx/issues/6766.

Linking external documentation in Sphinx

I am trying to link from our project's extension documentation to the core documentation in Sphinx. I've tried intersphinx, but from what I see it only supports objects, while our documentation doesn't refer to objects, it's just plain .rst.
I've added
intersphinx_mapping = {
'project': ('http://link-to-readthedocs/index.html', None),
}
to conf.py and edited the link to :ref:\`Documentation\` and later :doc:\`Documentation\` . It didn't work.
The question:
How to link from one projects' documentation to another in Sphinx for plain .rst files (not objects)?
Edit: I've done make html, found my objects.inv, but now I guess I only have it locally? I'm not sure what I'm doing anymore, but when I try to check the object references, I get:
UserWarning: intersphinx inventory 'http://myproject.com/index.html/objects.inv' not fetchable due to <class 'urllib.error.HTTPError'>: HTTP Error 404: Not Found
'%s: %s' % (inv, err.__class__, err))
The first thing to fix here is the link you've included to the base URL of your project docs:
intersphinx_mapping = {
'project': ('http://link-to-readthedocs/index.html', None),
}
According to the intersphinx docs:
A dictionary mapping unique identifiers to a tuple (target, inventory). Each target is the base URI of a foreign Sphinx documentation set and can be a local path or an HTTP URI. The inventory indicates where the inventory file can be found: it can be None (at the same location as the base URI) or another local or HTTP URI.
Thus, the error is in having the index.html at the end of your target. It should instead look something like this:
intersphinx_mapping = {
'project': ('http://project.readthedocs.io/en/latest', None),
}
If desired, replace en with the preferred docs language, and latest with the preferred RtD built version of the docs.

Adding a custom installation directory option to Autoconf-generated configure scripts

configure scripts always include something like the following in the help message:
...
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root
[DATAROOTDIR/doc/gedit-line-ending-style-plugin]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
...
What I would like to do is add "plugindir", to this section, as in:
...
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
--plugindir=DIR Gedit plugin files [LIBDIR/gedit-2/plugins]
...
so that users would be able to pass in --plugindir=... to the configure script.
How can I do this?
Put the following lines in configure.ac, near the beginning:
AC_ARG_WITH([pkgconfigdir],
[AS_HELP_STRING([--with-pkgconfigdir=DIR], [pkgconfig files])],
[pkgconfigdir=$withval],
[pkgconfigdir="\${libdir}/pkgconfig"])
AC_SUBST([pkgconfigdir], [$pkgconfigdir])
Then, in Makefile.am, you can refer to the directory like this:
pkgconfigdir = #pkgconfigdir#
pkgconfig_DATA = mylibrary.pc
If I'm correct those paths are set in the share/autoconf/autoconf/general.m4 file. The list is hardcoded so it is difficult to insert things in the list. You can add extra help information using the macro AS_HELP_STRING.
There are some examples that add a plugindir, for example in gstreamer, gimp, but those don't have a configurable plugin directory.
I think you are on the right track with AC_SUBST.
Additionally, I think you can modify or extend the --help output of configure with AS_HELP_STRING.
See: http://www.gnu.org/s/hello/manual/autoconf/Pretty-Help-Strings.html

Resources