cython icon indicating copy to clipboard operation
cython copied to clipboard

Doc: Modernize pure mode tutorial (pure.rst) with dual syntax tabs

Open Mars-aliens opened this issue 2 months ago • 15 comments

Title: Doc: Modernize pure mode tutorial (pure.rst) with dual syntax tabs

Description:

This PR completes the modernization of the documentation structure in docs/src/tutorial/pure.rst by converting all isolated code blocks and single .. literalinclude:: references into the unified, dual-syntax .. tabs:: structure (Pure Python vs. Traditional Cython).

This change significantly improves the clarity and maintainability of the tutorial, allowing users to easily compare the Pure Python method with the traditional Cython equivalent side-by-side.

Key Changes:

  • Global Conversion: Most tutorial examples now use the .. tabs:: structure.
  • New Examples: Created corresponding .pyx files for nearly all Pure Python examples (e.g., exceptval_syntax.pyx, type_hints.pyx, c_arrays.pyx).
  • RST Cleanup: Resolved indentation issues and updated surrounding text for consistency with the new structure.

I have verified the build using make html locally, and there are no warnings or errors related to the file structure.

Mars-aliens avatar Nov 05 '25 08:11 Mars-aliens

Thank you for your contribution! I had a quick look. It contains generated .cpp file (docs/examples/userguide/wrapping_CPlusPlus/rect_with_attributes.cpp). The file was commited by mistake I suppose.

matusvalo avatar Nov 06 '25 10:11 matusvalo

Thank you for your contribution! I had a quick look. It contains generated .cpp file (docs/examples/userguide/wrapping_CPlusPlus/rect_with_attributes.cpp). The file was commited by mistake I suppose.

@matusvalo

Hello,

I'm also a new contributor and would like to help modernize the pages in issue #4187 ([ENH] Pythonise the documentation! )that haven't been completed yet.

But scoder said "It might be the last of the listed pages that can be presented in both variants at this stage."(" It "refers to the work of Mars-aliens . ) Does this mean that these unfinished pages are no longer able to be completed?

I'm a greenhand and I'm eager to make contribution to cython. Please let me know that if I still want to work on this task, which page would be a good one to start with?

Thanks!

Re1nyyy avatar Nov 06 '25 11:11 Re1nyyy

You can run the relevant tests with:

python3 runtests.py -vv --no-file --no-doctest --no-unit

(that's more just disabling most of the other tests, but that should be enough for you to test if your examples work relatively quickly)

da-woods avatar Nov 06 '25 18:11 da-woods

The failure in the Benchmarks workflow appears unrelated to this PR. This change only touches documentation, so no benchmark CSV files are produced, and the benchmark_results_*.csv glob resolves to an empty list, causing the script to error.

Mars-aliens avatar Nov 11 '25 06:11 Mars-aliens

The documentation looks good.

The benchmark changes definitely shouldn't be part of this PR, and I don't think we need them at all. I didn't see the actual failure they were claiming to fix but I suspect it might have just been a random failure to connect to github (which happens sometimes) and not anything that needs fixing

da-woods avatar Nov 11 '25 21:11 da-woods

There is also change in .github/workflows/ci.yml. Is it needed for this PR? I would remove it or move to separate PR...

matusvalo avatar Nov 12 '25 20:11 matusvalo

I think there is good progress with the PR. I added several comments...

matusvalo avatar Nov 12 '25 21:11 matusvalo

You're right — the change in github/workflows/ci.yml isn’t needed for this PR. It was added while testing some benchmark issues but isn’t required anymore. I’ll remove it in the next update.

Mars-aliens avatar Nov 13 '25 04:11 Mars-aliens

I think you ended up changing the line endings in some files. Please revert that, or just replace them with standard Unix line endings everywhere.

Hi! Following up on this PR since it’s blocking some of my next steps. Please take a look when you’re available. Thank you!

Mars-aliens avatar Nov 27 '25 02:11 Mars-aliens

@scoder Hi! Just following up on this PR since it has been a while. Please let me know if there’s anything I should improve or adjust. Thanks!

Mars-aliens avatar Nov 28 '25 02:11 Mars-aliens

@matusvalo Hi, just a friendly reminder on this PR since it's been a while. Let me know if there’s anything I should update or revise. Appreciate your review!

Mars-aliens avatar Dec 03 '25 09:12 Mars-aliens

There's definitely still a bunch of files which are identical except for line ending whitespace changes (your editor has substituted /n for /r/n) which should be undone. That might be fixed with the git core.autocrlf setting?

da-woods avatar Dec 04 '25 08:12 da-woods

There's definitely still a bunch of files which are identical except for line ending whitespace changes (your editor has substituted /n for /r/n) which should be undone. That might be fixed with the git core.autocrlf setting?

Thanks for the hint! I’ve fixed the CRLF issues — my editor had indeed introduced \r\n line endings.

I’ve converted the affected files back to consistent LF line endings and removed all trailing whitespace.
git show --check is now clean.

I’ve also updated my git config (core.autocrlf=false) to prevent this from happening again.

Mars-aliens avatar Dec 09 '25 13:12 Mars-aliens

There's definitely still a bunch of files which are identical except for line ending whitespace changes (your editor has substituted /n for /r/n) which should be undone. That might be fixed with the git core.autocrlf setting?

Thanks for the hint! I’ve fixed the CRLF issues — my editor had indeed introduced \r\n line endings.

Unfortunately I don't think they're fixed. ‎docs/examples/tutorial/pure/A_equivalent.pyx‎ for example is apparently identical but shows up with every line changed on the github UI

da-woods avatar Dec 09 '25 21:12 da-woods

There's definitely still a bunch of files which are identical except for line ending whitespace changes (your editor has substituted /n for /r/n) which should be undone. That might be fixed with the git core.autocrlf setting?

Thanks for the hint! I’ve fixed the CRLF issues — my editor had indeed introduced \r\n line endings.

Unfortunately I don't think they're fixed. ‎docs/examples/tutorial/pure/A_equivalent.pyx‎ for example is apparently identical but shows up with every line changed on the github UI

Hi @da-woods, I've checked the files carefully and fixed the CRLF issues. All relevant files now have consistent Unix-style line endings (\n). For example, docs/examples/tutorial/pure/A_equivalent.pyx no longer contains any \r characters. Please let me know if you still see any issues.

Mars-aliens avatar Dec 10 '25 12:12 Mars-aliens

Mostly fine now, but I also had a few comments. Once the remaining ones are resolved, I think this'll be done.

Thanks for the detailed feedback! I've incorporated the suggested changes and updated the PR. Happy to adjust further if needed.

Mars-aliens avatar Dec 21 '25 06:12 Mars-aliens