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 links to code refs in docs #3025

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions include/prism.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ PRISM_EXPORTED_FUNCTION void pm_dump_json(pm_buffer_t *buffer, const pm_parser_t
* In order to parse Ruby code, the structures and functions that you're going
* to want to use and be aware of are:
*
* * `pm_parser_t` - the main parser structure
* * `pm_parser_init` - initialize a parser
* * `pm_parse` - parse and return the root node
* * `pm_node_destroy` - deallocate the root node returned by `pm_parse`
* * `pm_parser_free` - free the internal memory of the parser
* * <code>#pm_parser_t</code> - the main parser structure
* * `pm_parser_init()` - initialize a parser
* * `pm_parse()` - parse and return the root node
* * `pm_node_destroy()` - deallocate the root node returned by `pm_parse()`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I can't find pm_node_destroy in the docs (and neither can Doxygen. Any clue what's up with that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know

* * `pm_parser_free()` - free the internal memory of the parser
*
* Putting all of this together would look something like:
*
Expand All @@ -280,9 +280,9 @@ PRISM_EXPORTED_FUNCTION void pm_dump_json(pm_buffer_t *buffer, const pm_parser_t
* }
* ```
*
* All of the nodes "inherit" from `pm_node_t` by embedding those structures as
* All of the nodes "inherit" from <code>#pm_parser_t</code> by embedding those structures as
* their first member. This means you can downcast and upcast any node in the
* tree to a `pm_node_t`.
* tree to a \ref pm_parser_t "<code>pm_parser_t *</code>".
*
* @section serializing Serializing
*
Expand All @@ -292,10 +292,10 @@ PRISM_EXPORTED_FUNCTION void pm_dump_json(pm_buffer_t *buffer, const pm_parser_t
* parse Ruby code. The structures and functions that you're going to want to
* use and be aware of are:
*
* * `pm_buffer_t` - a small buffer object that will hold the serialized AST
* * `pm_buffer_free` - free the memory associated with the buffer
* * `pm_serialize` - serialize the AST into a buffer
* * `pm_serialize_parse` - parse and serialize the AST into a buffer
* * #pm_buffer_t - a small buffer object that will hold the serialized AST
* * #pm_buffer_free() - free the memory associated with the buffer
* * #pm_serialize() - serialize the AST into a buffer
* * #pm_serialize_parse() - parse and serialize the AST into a buffer
*
* Putting all of this together would look something like:
*
Expand All @@ -313,7 +313,7 @@ PRISM_EXPORTED_FUNCTION void pm_dump_json(pm_buffer_t *buffer, const pm_parser_t
* @section inspecting Inspecting
*
* Prism provides the ability to inspect the AST by pretty-printing nodes. You
* can do this with the `pm_prettyprint` function, which you would use like:
* can do this with the pm_prettyprint() function, which you would use like:
*
* ```c
* void prettyprint(const uint8_t *source, size_t length) {
Expand Down
8 changes: 4 additions & 4 deletions include/prism/util/pm_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ typedef struct {
/** The length of the string in bytes of memory. */
size_t length;

/** The type of the string. This field determines how the string should be freed. */
enum {
/** The type of the string, which determines how the string should be freed. */
enum pm_string_type {
Copy link
Contributor Author

@amomchilov amomchilov Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This anonymous enum made broke the docs, but also gave worse in-editor feedback.

Before:

Screenshot 2024-08-30 at 2 48 58 PM

After:

image

/** This string is a constant string, and should not be freed. */
PM_STRING_CONSTANT,

/** This is a slice of another string, and should not be freed. */
PM_STRING_SHARED,

/** This string owns its memory, and should be freed using `pm_string_free`. */
/** This string owns its memory, and should be freed using \ref pm_string_free "<code>pm_string_free()</code>". */
PM_STRING_OWNED,

#ifdef PRISM_HAS_MMAP
/** This string is a memory-mapped file, and should be freed using `pm_string_free`. */
/** This string is a memory-mapped file, and should be freed using \ref pm_string_free "<code>pm_string_free()</code>". */
PM_STRING_MAPPED
#endif
} type;
Expand Down
Loading