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

Allow definition of "helper functions" #7

Open
agnoster opened this issue Aug 14, 2012 · 0 comments
Open

Allow definition of "helper functions" #7

agnoster opened this issue Aug 14, 2012 · 0 comments

Comments

@agnoster
Copy link
Owner

There should be a way to define and call helper functions like "log in" or "today's date", etc.

However, we need to define:

Where should the functions be defined?

We could search some "base" directory for a literapi.js file, or similar. Or we could have a -I "include" flag for literapi that points to a file to be included.

How should the functions be called from the LiterAPI doc?

Simply having some special syntax seems like it would defeat the human-readability of LiterAPI, and obscure the meaning. Since there are no comments in Markdown, there's no good way to embed a function call (unless added to the opening fence of a code block, but that feels... hacky).

We could do some kind of text-matching a la cucumber, so something like

> NB: We assume a logged-in user. See [[Authentication]] for more details.

Would be matched by

literapi.match(/^We assume a logged-in-user./, function(){ ... })

(In this case, assuming "NB" is a well-defined scope prefix so it's easy to find all LiterAPI directives in a document.)

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

No branches or pull requests

1 participant