Skip to content

link C docs from R docs #1317

Closed
Closed

Description

@maelle

in each manual page.

Find a way to make that automatic.

cc @szhorvat

Activity

  1. self-assigned this
    on Mar 22, 2024
  2. maelle commented on Aug 30, 2024

    @maelle
    ContributorAuthor

    It would not need to be automatic.

    We could add a special tag automatically for already exposed functions, and manually for new exposed functions.

  3. maelle commented on Aug 30, 2024

    @maelle
    ContributorAuthor

    for each function that is defined as or wraps an _impl function we can find what is .Call inside it.

    Now from say R_igraph_empty we can know we want to link to igraph_empty. How do we find the link to https://igraph.org/c/doc/igraph-Basic.html#igraph_empty?

    We could parse the docs folder of the C library every time we update the vendored file. In each xxml file there are links like

    https://github.com/igraph/igraph/blob/03760a09cc7195dfaad3a1e60cff1632aa6a6118/doc/basicigraph.xxml#L176

    so for each xxml file we can know what C things are documented in it.

  4. maelle commented on Aug 30, 2024

    @maelle
    ContributorAuthor

    so the tag we'd add would be something like

    #'  @cmethod igraph_empty
    

    and we'd use an internal lookup table to know in which chapter of the C docs it is documented.

  5. szhorvat commented on Aug 30, 2024

    @szhorvat
    Member

    How do we find the link to https://igraph.org/c/doc/igraph-Basic.html#igraph_empty?

    You can parse the index, https://igraph.org/c/html/latest/ix01.html

    The name of the target to build docs for C locally is html.

    so for each xxml file we can know what C things are documented in it.

    Trying to get this from xxml files isn't going to be reliable.


    Be careful, some R functions map to multiple C functions! Example distances().

  6. maelle commented on Aug 30, 2024

    @maelle
    Author
  7. maelle commented on Aug 30, 2024

    @maelle
    Author
  8. szhorvat commented on Aug 30, 2024

    @szhorvat
    Member

    Or just skip these special ones for now.

  9. maelle commented on Aug 30, 2024

    @maelle
    Author
  10. maelle commented on Aug 30, 2024

    @maelle
    Author
  11. maelle commented on Aug 30, 2024

    @maelle
    Author
  12. maelle commented on Aug 30, 2024

    @maelle
    Author
  13. maelle commented on Aug 30, 2024

    @maelle
    Author
  14. szhorvat commented on Aug 30, 2024

    @szhorvat
    Member

    @szhorvat I don't see the several igraph methods distances() is calling?

    This is why I suggested to skip these special cases for now. The interface is often sufficiently different that the C docs are less relevant. That said, you can see it like this:

    Look up that distances() calls R_igraph_shortest_paths():

    R_igraph_shortest_paths, graph, v - 1, to - 1,

    This does NOT mean that this maps to igraph_shortest_paths(). We have to find where R_igraph_shortest_paths() comes from. In this case, it is not auto-generated, so it's found in rinterface_extra.c:

    SEXP R_igraph_shortest_paths(SEXP graph, SEXP pvids, SEXP pto,

    Looking at the sources, you'll see that currently it makes use of several functions such as igraph_distances, igraph_distances_dijkstra, igraph_distances_bellman_ford, distances_johnson, igraph_distances_floyd_warshall, and even calls the locally defined distances_johnson, which in turn calls others:

    static igraph_error_t distances_johnson(const igraph_t *graph,

    If you see the _impl, that means full auto-generation, so predictability.

  15. maelle commented on Sep 6, 2024

    @maelle
    ContributorAuthor

    For a function that .Call()s R_igraph_square_lattice how do I know what igraph functions R_igraph_square_lattice calls? Here's what I think I understand:

    • If I find "igraph_square_lattice" in tools/stimulus/functions.yaml (or tools/stimulus/functions-R.yaml, which one to use?) it means the igraph function really is "igraph_square_lattice". Or can I simply use the index of the C docs? Edit: no as there's for instance a C function called igraph_shortest_paths so best to use the stimulus YAML.

    • If not it means I have to parse src/rinterface_extra.c. I should try and get better at treesitter then 😅 (which in R only has the grammar for R Include other languages? DavisVaughan/r-tree-sitter#21

  16. maelle commented on Sep 6, 2024

    @maelle
    ContributorAuthor

    But if I start by functions that are/wrap _impl functions then it's easy, as you said.

  17. reopened this on Sep 6, 2024
  18. maelle commented on Sep 6, 2024

    @maelle
    ContributorAuthor

    Regarding src/rinterface_extra.c what we need is for each function defined inside it, to know what igraph function it calls but limited to those igraph functions that are in igraph manual. For instance, a function that calculates the size of a vector is not relevant for our purposes.

  19. schochastics commented on May 29, 2026

    @schochastics
    Contributor

    @maelle I feel like this is done or am I wrong?

  20. maelle commented on Jun 2, 2026

    @maelle
    ContributorAuthor

    Yes, how could I forget to close the issue? Thanks so much for letting me click this button 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions