Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tutorial for bindings #102

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

inknos
Copy link
Collaborator

@inknos inknos commented Oct 20, 2022

This pr adds documentation for language bindings.

Currently, the PR aims to replicate the c++ tutorial section in python and, subsequently, to other languages.

image
image
image

To test tutorials the dir test/python3/libdnf5/tutorial is soft-linked to doc/tutorials/tests/bindings/python3

├── api
├── contributing
├── dnf_daemon
├── sphinx
├── templates
│   └── command
└── tutorial
    ├── bindings
    │   ├── go
    │   ├── perl5
    │   ├── python3
    │   └── ruby
    └── tests -> ../../test/tutorial
        ├── bindings
        │   ├── perl5 -> ../../perl5/libdnf5/tutorial
        │   └── python3 -> ../../python3/libdnf5/tutorial/
        │       ├── query
        │       ├── repo
        │       ├── session
        │       └── transaction
        ├── query
        ├── repo
        ├── session
        └── transaction

There are a few things that can be reviewed already and some that are still work in progress.

  • documentation structure
  • porting tutorial from c++ to pyhton3 (transaction.py needs to be fixed in swig first)
  • testing python scripts during build (load local repo does not work at the moment, but should work outside of tests)

Eventually this work will be the base to implement tutorial for other bindings

  • porting tutorial from c++ to ruby
  • porting tutorial from c++ to perl
  • porting tutorial from c++ to go

@inknos inknos force-pushed the ns-tutorial-python branch 2 times, most recently from 1c5a8e9 to ccefaff Compare October 20, 2022 18:36
@inknos inknos force-pushed the ns-tutorial-python branch from ccefaff to 64a1cec Compare November 7, 2022 17:40
@inknos inknos marked this pull request as ready for review November 7, 2022 17:40
@jan-kolarik jan-kolarik self-assigned this Nov 8, 2022
@inknos inknos force-pushed the ns-tutorial-python branch from 64a1cec to c79f048 Compare November 8, 2022 17:12
@inknos inknos force-pushed the ns-tutorial-python branch from c79f048 to 3984149 Compare November 15, 2022 15:03
@jan-kolarik
Copy link
Member

I can confirm that the python bindings tutorial is reflecting the current cpp tutorial state, except the mentioned transactions. Tests are passing and HTML output seems correct.

This commit adds the main structure for the documentation of language
bindings. It serves its purpose by showing a minimal working example
for python3.

The dir test/python3/libdnf5/tutorial is soft-linked to
doc/tutorials/tests/bindings/python3.
This allows us to use the documentation snippets in testing.

The purpose of including tutorials' code in unit tests is to ensure
they would be interpreted without errors if run in sequence.
Specifically, these tests do not assert anything on the results one
could get by calling the API. They provide testing on the functional
part of dnf5's language bindings.

Inside test/tutorial/binding/python3/test_tutorial.py each snippet is
imported via `exec`.
Although this is usually a bad practice, calling `exec` allows the tests
to run all the snippets in a sequence, as if a user would copy-paste
the code in a single example.
As stated previously, these tests do not assert anything on the results
of the called API functions. Hence, `exec` is considered to be safe in
this instance.
@inknos inknos force-pushed the ns-tutorial-python branch from a9b509e to f8afe85 Compare November 25, 2022 14:35
@jan-kolarik jan-kolarik merged commit fa70b66 into rpm-software-management:main Nov 28, 2022
@inknos inknos deleted the ns-tutorial-python branch June 27, 2023 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants