Skip to content

[CLIENT-4702] Fix several code examples in the API docs. Add smoke test to check that code examples are valid using doctest#1047

Merged
juliannguyen4 merged 121 commits into
devfrom
CLIENT-4702-doc-validate-code-examples-using-doctest
Jun 5, 2026
Merged

[CLIENT-4702] Fix several code examples in the API docs. Add smoke test to check that code examples are valid using doctest#1047
juliannguyen4 merged 121 commits into
devfrom
CLIENT-4702-doc-validate-code-examples-using-doctest

Conversation

@juliannguyen4

@juliannguyen4 juliannguyen4 commented Apr 26, 2026

Copy link
Copy Markdown
Collaborator

This addresses all the code examples in aerospike_helpers, as well as most of the code examples in the docs for aerospike and aerospike.Client.

There are still some code examples aren't tested yet e.g because they are incomplete, require EE features, or I didn't have time to get to the remaining code examples in this sprint. There is another PR to address those: #1096

Extra Changes

  • Replaced the code example for client.udf_put(), client.udf_list(), and client.udf_remove() with a higher level code example for the "User Defined Functions" section. The latter is verified to run without errors using doctest and demonstrates the outcomes of those API calls.
  • Add ability to copy code examples while also stripping any characters that aren't valid Python syntax
  • Remove bad code example for HyperLogLog class. Normally, HyperLogLog bins are created using operations or expressions.

Known issues introduced here

  • Documentation for aerospike.Client: The testsetup code block isn't visible by default, so we have to have a duplicate codeblock to show that code. This introduces some technical debt, and having the testsetup code visible is a missing feature in Sphinx

Trade-offs

  • Code examples are harder to run because the Python REPL gives a syntax error when it encounters >>>. As a workaround, developers have to use IPython REPL with their specific desired version of Python to copy and run the code examples

Manual testing

TODO

  • aerospike needs to be compiled before running doctest
  • Copying doctest formatted code into Python REPL causes syntax errors related to >>> Moved to a different format from doctest

Out of scope

  • Doctest teardown
  • client.info_all() output format is kinda weird...

@codecov-commenter

codecov-commenter commented Apr 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.46%. Comparing base (5bc339b) to head (d4999e6).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1047   +/-   ##
=======================================
  Coverage   84.46%   84.46%           
=======================================
  Files          99       99           
  Lines       14088    14090    +2     
=======================================
+ Hits        11899    11901    +2     
  Misses       2189     2189           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…the TLS test which needs to be run with a different job
…uple that contains the line number where it happened which isn't important
… run boilerplate code before each example in client.rst
…y code example. It doesn't seem possible with doctest + unittest
@juliannguyen4 juliannguyen4 marked this pull request as ready for review June 4, 2026 20:46
@juliannguyen4 juliannguyen4 changed the title [CLIENT-4702] Convert docstring code examples to doctest format and validate them [CLIENT-4702] Validate most of the code examples in the API docs (using a community edition server) Jun 4, 2026
@juliannguyen4 juliannguyen4 changed the title [CLIENT-4702] Validate most of the code examples in the API docs (using a community edition server) [CLIENT-4702] Validate most of the code examples in the API docs (i.e the ones that are compatible with a community edition server) Jun 4, 2026
@juliannguyen4 juliannguyen4 changed the title [CLIENT-4702] Validate most of the code examples in the API docs (i.e the ones that are compatible with a community edition server) [CLIENT-4702] Validate the majority of the code examples in the API docs (i.e the ones that are compatible with a community edition server) Jun 4, 2026
@juliannguyen4 juliannguyen4 force-pushed the CLIENT-4702-doc-validate-code-examples-using-doctest branch from e051e8e to d4999e6 Compare June 4, 2026 21:38
@juliannguyen4 juliannguyen4 changed the title [CLIENT-4702] Validate the majority of the code examples in the API docs (i.e the ones that are compatible with a community edition server) [CLIENT-4702] Fix several code examples in the API docs. Add smoke test to check that code examples are valid Jun 4, 2026
@juliannguyen4 juliannguyen4 changed the title [CLIENT-4702] Fix several code examples in the API docs. Add smoke test to check that code examples are valid [CLIENT-4702] Fix several code examples in the API docs. Add smoke test to check that code examples are valid using doctest Jun 4, 2026
@juliannguyen4 juliannguyen4 merged commit 79c6dfe into dev Jun 5, 2026
43 of 44 checks passed
@juliannguyen4 juliannguyen4 deleted the CLIENT-4702-doc-validate-code-examples-using-doctest branch June 5, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants