Skip to content

linking to language translations using intersphinx? #8342

Closed

Description

@danbjoseph

Is your feature request related to a problem? Please describe.
I have multiple languages of a general documentation website and I'd like to be able to use intersphinx to link between them.

Additional context
I seem to be able to get info from language specific docs. For example from the English Python docs, running...
python -msphinx.ext.intersphinx https://docs.python.org/3/objects.inv
and getting...

std:doc
	about                                    About these documents                   : about.html
	bugs                                     Dealing with Bugs                       : bugs.html

And then from Spanish Python docs, running...
python -msphinx.ext.intersphinx https://docs.python.org/es/3/objects.inv
and getting...

std:doc
	about                                    Acerca de estos documentos              : about.html
	bugs                                     Lidiar con errores                      : bugs.html

I set the following in my conf.py file:

intersphinx_mapping = {
    'python': ('https://docs.python.org/3/', None),
    'pythones': ('https://docs.python.org/es/3/', None)
}

And I was expecting to be able to add the following to the .rst file for a page of my site:

- :python:doc:`about <about>`
- :pythones:doc:`about (es) <about>`

But I get the same link href for both:

<ul class="simple">
    <li><p><a class="reference external" href="https://docs.python.org/3/about.html" title="(in Python v3.9)"><span class="xref std std-doc">about</span></a></p></li>
    <li><p><a class="reference external" href="https://docs.python.org/3/about.html" title="(in Python v3.9)"><span class="xref std std-doc">about (es)</span></a></p></li>
</ul>

And I can't see a way to get the right URL path for the additional languages.

Activity

  1. added
    type:enhancement
    on Oct 26, 2020
  2. Calinou commented on Oct 26, 2020

    @Calinou

    Maybe the research done in this PR can help you? godotengine/godot-docs#3279

  3. tk0miya commented on Oct 27, 2020

    @tk0miya
    Member

    :python:doc:`about <about>` is not a valid notation. Please use :doc:`about <python:about>` . Then you can choose external project on referring expectedly.

  4. added and removed
    type:enhancement
    on Oct 27, 2020
  5. added a commit that references this issue on Oct 27, 2020
    9cd3e1a
  6. danbjoseph commented on Oct 27, 2020

    @danbjoseph
    Author

    @Calinou - Thank you for the link, I'll take a look.
    @tk0miya - Oddly, when I've set my conf.py file as written above and I try to use the notation you provide, it doesn't seem to be generating the links. So I think I must be doing something wrong in another place. When i run sphinx-build --version it outputs sphinx-build 3.2.1.

    In the .rst file:

    :python:doc:`about <about>`
    
    :pythones:doc:`about (es) <about>`
    
    :doc:`about <python:about>`
    
    :doc:`about <pythones:about>`
    

    In the html output:

    <p><a class="reference external" href="https://docs.python.org/3/about.html" title="(in Python v3.9)"><span class="xref std std-doc">about</span></a></p>
    <p><a class="reference external" href="https://docs.python.org/3/about.html" title="(in Python v3.9)"><span class="xref std std-doc">about (es)</span></a></p>
    <p><span class="xref std std-doc">about</span></p>
    <p><span class="xref std std-doc">about</span></p>
    
  7. added a commit that references this issue on Nov 3, 2020
    b93aa31
  8. tk0miya commented on Nov 3, 2020

    @tk0miya
    Member

    Could you check your intersphinx_mapping setting, please? And please check the output of the sphinx build. Are there any warnings about :doc: reference?

    FYI: Here's result of my trial:

    $ mkdir tmp
    $ cd tmp/
    $ LC_ALL=C sphinx-quickstart -q -a author -p project .
    
    Finished: An initial directory structure has been created.
    
    You should now populate your master file /Users/tkomiya/work/tmp/doc/tmp/index.rst and create other documentation
    source files. Use the Makefile to build the docs, like so:
       make builder
    where "builder" is one of the supported builders, e.g. html, latex or linkcheck.
    
    $ echo '' >> conf.py
    $ echo 'extensions = ["sphinx.ext.intersphinx"]' >> conf.py
    $ echo "intersphinx_mapping = {
    >     'python': ('https://docs.python.org/3/', None),
    >     'pythones': ('https://docs.python.org/es/3/', None)
    > }" >> conf.py
    $ echo 'test
    > ====
    >
    > :python:doc:`about <about>`
    >
    > :pythones:doc:`about (es) <about>`
    >
    > :doc:`about <python:about>`
    >
    > :doc:`about <pythones:about>`' > index.rst
    $ tail conf.py
    
    # Add any paths that contain custom static files (such as style sheets) here,
    # relative to this directory. They are copied after the builtin static files,
    # so a file named "default.css" will overwrite the builtin "default.css".
    html_static_path = ['_static']
    extensions = ["sphinx.ext.intersphinx"]
    intersphinx_mapping = {
        'python': ('https://docs.python.org/3/', None),
        'pythones': ('https://docs.python.org/es/3/', None)
    }
    $ cat index.rst
    test
    ====
    
    :python:doc:`about <about>`
    
    :pythones:doc:`about (es) <about>`
    
    :doc:`about <python:about>`
    
    :doc:`about <pythones:about>`
    $ LC_ALL=C make clean html
    Removing everything under '_build'...
    Running Sphinx v3.4.0+/c028fb7a4
    making output directory... done
    loading intersphinx inventory from https://docs.python.org/3/objects.inv...
    loading intersphinx inventory from https://docs.python.org/es/3/objects.inv...
    building [mo]: targets for 0 po files that are out of date
    building [html]: targets for 1 source files that are out of date
    updating environment: [new config] 1 added, 0 changed, 0 removed
    reading sources... [100%] index
    looking for now-outdated files... none found
    pickling environment... done
    checking consistency... done
    preparing documents... done
    writing output... [100%] index
    generating indices... genindex done
    writing additional pages... search done
    copying static files... done
    copying extra files... done
    dumping search index in English (code: en)... done
    dumping object inventory... done
    build succeeded.
    
    The HTML pages are in _build/html.
    $ grep about _build/html/index.html
    <p><a class="reference external" href="https://docs.python.org/es/3/about.html" title="(in Python v3.9)"><span class="xref std std-doc">about</span></a></p>
    <p><a class="reference external" href="https://docs.python.org/es/3/about.html" title="(in Python v3.9)"><span class="xref std std-doc">about (es)</span></a></p>
    <p><a class="reference external" href="https://docs.python.org/3/about.html" title="(in Python v3.9)"><span class="xref std std-doc">about</span></a></p>
    <p><a class="reference external" href="https://docs.python.org/es/3/about.html" title="(in Python v3.9)"><span class="xref std std-doc">about</span></a></p>
    $
    
  9. tk0miya commented on Nov 12, 2020

    @tk0miya
    Member

    I'm closing this now. Please feel free to reopen if you are still in the problem.
    Thanks,

  10. added a commit that references this issue on Mar 11, 2021
    3134085
  11. locked as resolved and limited conversation to collaborators on Jul 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions