Repository: cython/cython

Issue:
[BUG] Example code has compilation error in cython tutorial - Primes with C++
**Describe the bug**

I encountered a bug when following [cython tutorial - Primes with C++](https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html#primes-with-c)

I used the [code](https://github.com/cython/cython/blob/master/docs/examples/tutorial/cython_tutorial/primes_cpp.py) which is presented in the tutorial, and named it to `primes_vec.py`. I used the `setup.py` (shown below) to compile it, but it failed with error.

```python
from setuptools import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize(
        [
            'primes_vec.py',
        ],
        annotate=True,
    ),
)
```

```shell
python setup.py build_ext --inplace
Compiling primes_vec.py because it changed.
[1/1] Cythonizing primes_vec.py
/home/user/anaconda3/envs/cython/lib/python3.10/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /path/CythonPractice/prime/primes_vec.py
  tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:
------------------------------------------------------------
...
from cython.cimports.libcpp.vector import vector

def primes(nb_primes: cython.uint):
    i: cython.int
    p: vector[cython.int]
    p.reserve(nb_primes)  # allocate memory for 'nb_primes' elements.
   ^
------------------------------------------------------------

primes_vec.py:9:4: local variable 'p' referenced before assignment

Error compiling Cython file:
------------------------------------------------------------
...
    i: cython.int
    p: vector[cython.int]
    p.reserve(nb_primes)  # allocate memory for 'nb_primes' elements.

    n: cython.int = 2
    while p.size() < nb_primes:  # size() for vectors is similar to len()
         ^
------------------------------------------------------------

primes_vec.py:12:10: local variable 'p' referenced before assignment

Error compiling Cython file:
------------------------------------------------------------
...
    p: vector[cython.int]
    p.reserve(nb_primes)  # allocate memory for 'nb_primes' elements.

    n: cython.int = 2
    while p.size() < nb_primes:  # size() for vectors is similar to len()
        for i in p:
                ^
------------------------------------------------------------

primes_vec.py:13:17: local variable 'p' referenced before assignment

Error compiling Cython file:
------------------------------------------------------------
...
    while p.size() < nb_primes:  # size() for vectors is similar to len()
        for i in p:
            if n % i == 0:
                break
        else:
            p.push_back(n)  # push_back is similar to append()
           ^
------------------------------------------------------------

primes_vec.py:17:12: local variable 'p' referenced before assignment

Error compiling Cython file:
------------------------------------------------------------
...
            p.push_back(n)  # push_back is similar to append()
        n += 1

    # If possible, C values and C++ objects are automatically
    # converted to Python objects at need.
    return p  # so here, the vector will be copied into a Python list.          ^
------------------------------------------------------------

primes_vec.py:22:11: local variable 'p' referenced before assignment
Traceback (most recent call last):
  File "/path/CythonPractice/prime/setup.py", line 5, in <module>
    ext_modules = cythonize(
  File "/home/user/anaconda3/envs/cython/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1103, in cythonize
    cythonize_one(*args)
  File "/home/user/anaconda3/envs/cython/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1226, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: primes_vec.py
```

**Environment (please complete the following information):**
 - OS: macOS
 - Python version: 3.10.0
 - Cython version 0.29.26



Discussion:
You probably have to use Cython 3.0 for this to work.
I'm not completely convinced that the pure Python syntax is a good default - it requires Cython 3.0 (and I suspect most people are on 0.29.x) and the docs don't make it that obvious which version they refer to. Using the "classic" syntax for the moment would probably avoid this confusion.
I tried again with `cython==3.0.0a10` and it worked fine.

So I guess we can add a comment to this code about the version it requires to avoid confusion?
> I'm not completely convinced that the pure Python syntax is a good default - it requires Cython 3.0 (and I suspect most people are on 0.29.x) and the docs don't make it that obvious which version they refer to. Using the "classic" syntax for the moment would probably avoid this confusion.

I am not 100% convinced that the main problem is default syntax. The problem can raise also when we introduce other changes in documentation - e.g. migration default version of `build_ext` - #4498. I think we should do 2 thinks:
1. by default documentation of stable version should be showed: https://cython.readthedocs.io/en/stable/ instead of https://cython.readthedocs.io/en/latest/
2. version of documentation should be clearly displayed. (maybe we can use https://sphinx-version-warning.readthedocs.io/en/latest/index.html)

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -184,6 +184,10 @@
     'css_files': ['_static/css/tabs.css'],
 }
 
+development = 'a' in release or 'b' in release
+
+html_context = {'development': development}
+
 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
 # using the given strftime format.
 #html_last_updated_fmt = '%b %d, %Y'


Test patch: