asciidoctor.js icon indicating copy to clipboard operation
asciidoctor.js copied to clipboard

add list of valid context names to findBy docs

Open StarfallProjects opened this issue 4 years ago • 4 comments

Proposal: add a list of valid context names to the findBy docs. I've added all the names I've found so far. However, if this docs repo PR is accepted (https://github.com/asciidoctor/asciidoc-docs/pull/90), it might be nicer to just add a link to the docs, rather than maintain the list in two places.

StarfallProjects avatar Sep 04 '21 15:09 StarfallProjects

@mojavelinux What do you think? Should we link to the documentation https://docs.asciidoctor.org/asciidoc/latest/blocks/#summary-of-built-in-contexts?

It might be confusing since Asciidoctor is using keyword :paragraph whereas Asciidoctor.js is using string...

Thoughts? 🤔

ggrossetie avatar Oct 18 '21 19:10 ggrossetie

Yes, I think we should link to the official list. As for the type (symbol or string) I think that can be clarified on both ends. I keep thinking to myself that that list should show strings, not symbols. Then we can explain elsewhere (such as in Asciidoctor) when a symbol is required. If you have suggestions for where to make those changes, I'm prepared to apply them.

mojavelinux avatar Oct 18 '21 19:10 mojavelinux

Then we can explain elsewhere (such as in Asciidoctor) when a symbol is required. If you have suggestions for where to make those changes, I'm prepared to apply them.

@mojavelinux Yes, that's a good idea. The implementation (Ruby) should state that context names should be passed as symbol. We could add a reference here: https://docs.asciidoctor.org/asciidoctor/latest/convert/templates/#backing-data-model

Although, this information is also useful when developping an extension, for instance here: https://docs.asciidoctor.org/asciidoctor/latest/extensions/block-processor/

on_context :paragraph

Or when using the find_by method.

Anyway, I think the "Backing data model" section is where we could introduce this concept. If we want to expand on that concept, we could talk about the following (related) methods:

  • https://www.rubydoc.info/gems/asciidoctor/2.0.16/Asciidoctor/AbstractNode#context-instance_method
  • https://www.rubydoc.info/gems/asciidoctor/2.0.16/Asciidoctor/AbstractBlock#find_by-instance_method
  • https://www.rubydoc.info/gems/asciidoctor/2.0.16/Asciidoctor/Extensions/BlockProcessor (:contexts option)

ggrossetie avatar Oct 22 '21 06:10 ggrossetie

I agree that when we're talking about the Ruby API, it should say there that the context must be passed as a symbol. We could also state on the Convertible Context page that whenever the context is used in the Ruby API, it must be a symbol, but AsciidoctorJ and Asciidoctor.js expect a string.

mojavelinux avatar Oct 22 '21 06:10 mojavelinux