json-ld icon indicating copy to clipboard operation
json-ld copied to clipboard

Feature Request (Docs): Add documentation for generic arguments

Open jcdickinson opened this issue 2 years ago • 1 comments

I am struggling to understand, at the very least, the full name for all the generic arguments. For example, what is a B? Providing the name only in the documentation would be a huge help.

Bonus points for a few examples of the types that might go into the generic args.

jcdickinson avatar Jan 17 '23 00:01 jcdickinson

Sorry for the trouble, yes it's lacking a lot of documentation.

For the record before I find time to continue writing the doc:

  • I is the type of IRIs. If you are not using a vocabulary it can be iref::IriBuf. Otherwise any type compatible with the IriVocabulary you are using. Sometimes this parameter is named T, this is an inconsistency I must solve.
  • B is the type of blank node identifiers. If you are not using a vocabulary it can be rdf_types::BlankIdBuf. Otherwise any type compatible with the BlankVocabulary you are using.
  • V is the vocabulary type if you are using any function ending in _with. It usually must implement IriVocabulary or BlankIdVocabulary (or their Mut counterpart), or both (shorthanded with the Vocabulary trait). It maps I to IRIs, and B to blank node identifiers. A common value for V is rdf_types::vocabulary::IndexVocabulary that works with I and B both equal to rdf_types::vocabulary::Index that is essentially a wrapper around usize.
  • G is the identifier generator type, implementing rdf_types::Generator. It is used by all the functions that need to generate fresh node identifiers. A good choice for G is rdf_types::generator::Blank that will generate fresh blank node identifiers.
  • L is the document loader type, implementing jsonld::Loader. It is used to load remote JSON-LD documents. Multiple loader implementation are provided, the most compliant to the JSON-LD spec being ReqwestLoader that can be enabled with the reqwest feature.
  • M is the metadata type. JSON-LD is a syntactic representation of an RDF dataset. This parameter is used to keep track of the position of each syntactic node in the original source file. You can use () if you are not interested in keeping this information. You can use locspan::Span to keep only the span in the source file, or locspan::Location<I> to keep the span along with the source file name (although it is not recommended if I is memory consuming, like IriBuf).

I think that's most of the parameters you will encounter.

timothee-haudebourg avatar Feb 02 '23 11:02 timothee-haudebourg