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 a helper function to inspect MyST AST objects in JavaScript (e.g. in utils) #1652

Open
choldgraf opened this issue Nov 18, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@choldgraf
Copy link
Collaborator

It's useful to be able to print log statements about the contents of AST, JavaScript objects, etc during a MyST build.
However, for print AST objects, using console.log isn't that useful.

If you do

console.log(ast)

It only generates the top layer of AST so you can't see what's in the children etc.

There are two other ways to print the full AST, but both are a pain to remember:

console.dir(ast, { depth: null, colors: true });

and

console.log(JSON.stringify(ast, null, 2))

Suggestion: make this a utility function

We should provide developers a utility function inside of utils or ctx that shows the contents of AST in a user-friendly way.

For example:

utils.inspect(ast, depth=3)
@choldgraf choldgraf added the enhancement New feature or request label Nov 18, 2024
choldgraf added a commit to jupyter-book/jupyter-book that referenced this issue Nov 19, 2024
This adds a tutorial for creating basic plugins with Jupyter Book. It
covers creating and registering plugins, creating a directive, and
creating a transform.

It also cleans up some navigation and adds two how-tos related to
plugins.

This is a result of some self-learning I had to do in creating some
plugins for my website, so hopefully this makes things easier to learn
for future readers!

### Follow ups

A few things I opened along the way:

- jupyter-book/mystmd#1651
- jupyter-book/mystmd#1649
- jupyter-book/mystmd#1652
- jupyter-book/mystmd#1654
- jupyter-book/mystmd#1655

---------

Co-authored-by: Angus Hollands <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant