sphinx-contrib / sphinxcontrib-versioning

Sphinx extension that allows building versioned docs for self-hosting.
https://sphinxcontrib-versioning.readthedocs.io/en/latest/
MIT License
127 stars 80 forks source link

Version number doesn't change #60

Open CukMonsta opened 5 years ago

CukMonsta commented 5 years ago

I used the fork of @leokoppel to generate the documentation, when I had installed that version of Sphinxcontrib-versioning I ran the following command: sphinx-versioning build docs/source/ docs/build/html

When I got the documentation, I opened it in my browser, everything was good, but when I tried to change between versions I saw the version numbers didn't change, the rest was fine.

With version numbers I mean that we use the |version| Sphinx replacement, and apparently it is always using the current/latest version instead of the actual version that is supposed to be used.

Follow the next steps to reproduce it:

git clone https://github.com/opensistemas-hub/osbrain.git
cd osbrain
python3.6 -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
pip install git+https://github.com/leokoppel/sphinxcontrib-versioning.git
sphinx-versioning build docs/source/ docs/build/html

Open the documentation in your browser and try to change between versions.

Somebody knows why the numbers don't change?

sehnem commented 5 years ago

Hi,

I'm having the same problem, but I think i know of what causes it.

In the steps to reproduce the problem you install the package, then you generate the documentation. Look how you pick the version for the documentation in your conf.py:

import osbrain

release = osbrain.__version__

This way you will always pick the version of the installed version.

In the conf.py from this package the version is picked from the setup file.

release = version = __import__('setup').VERSION

I think that changing it will solve the problem for you.

In my case I am using automatic versioning, so the versions are generated after the creation of the tag and I'm not able to take this approach. If someone knows what could I do, the package is https://gitlab.com/sehnem/pynmet.

Peque commented 5 years ago

@sehnem Thanks for your answer.

If I understood sphinxcontrib-versioning's behavior correctly, then it would not install the package version for which it is generating the documentation? In example: when it switches from 2.0.0 to 1.0.0 to generate the old docs, it would not actually install version 1.0.0 of the package before doing so?

If so, then I think it is a risky approach and could be worse than just having a non-expected value in the |version| number.

For example, a project that executes Python code that uses the package within the documentation. Imagine Matplotlib's documentation, where the output figures are auto-generated from the docs: if the correct version of Matplotlib is not installed before generating the docs then the output could be different, wrong or generation could even fail.

@sehnem What do you think? Could I be missing something or misunderstanding the current behavior? To be honest, I have not dig into sphinxcontrib-versioning's source code.

sehnem commented 5 years ago

@Peque

I have not worked a lot with this package, but I think that you cannot generate the documentation for each versions os the package since it builds all the documentation at once. If it is possible @Raythor approach should work, and it also would fix my problem.

I think that if it is not possible yet, implementing it would be useful for many applications. But maybe someone knows a way to make it work with different versions.