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 comment and ellipsis support to json lexer. #244

Merged

Conversation

textshell
Copy link

This pull request adds ellipsis support in addition to comment support from pull request 243.

Omitting key/value pairs with the comment syntax (i.e. // ... ) is awkward because if used at the end of an object you need to change the preceeding line to remove a trailing comma. This PR adds an syntax that looks better and also removes the special case when used at the end of an object.

Example:

    {
        "accountId": "someone@example.com",
        "id": "15",
        "addDate": "2015-01-01T00:00:00",
        "lastChangeDate": "2015-01-01T00:00:00",
        ...
    }

@jneen
Copy link
Member

jneen commented Mar 3, 2015

This is really cool! However, I'm a little hesitant to add it to the main json lexer. Would it be possible to create a new lexer for this instead? Maybe json-doc? You could even subclass JSON and use the prepend / append interface (see C++ for an example).

@jneen jneen closed this Mar 3, 2015
@jneen jneen reopened this Mar 3, 2015
@jneen
Copy link
Member

jneen commented Mar 3, 2015

(oops, accidentally closed)

@textshell
Copy link
Author

I'm implementing it as subclass of JSON which seems to be working out well.
Do you think it will be ok to keep json-doc in the javascript.rb file?
Do you have any advise what that subclass should use for filenames and mimetypes? I guess if i don't set anything they will be inherited from the JSON class, which might confuse auto detection?
C++ solves that by actually having a mime type and file extensions that can be used there, which is not really the case here.

Martin Hostettler added 3 commits March 3, 2015 18:07
While the json syntax doesn't allow for any comments it's often very useful to be able add inline comments in documentation or tutorials.
In documentation it is often helpful to be able to omit details not currently
relevant. In contrast to a comment, this syntax is allowed between a comma and
the end of an object. This allows for more uniform usage when omitting details
at the end of an object.
@textshell textshell force-pushed the feature-json-comment-and-ellipsis2 branch from 63fa327 to 18a2786 Compare March 3, 2015 17:33
@textshell
Copy link
Author

Did you have a chance to look at this? Will this work, or it there still something to fix?

@textshell
Copy link
Author

@jneen ping?

@jneen
Copy link
Member

jneen commented May 19, 2015

Sorry for the delay. Looks fantastic, thank you.

jneen added a commit that referenced this pull request May 19, 2015
…psis2

Add comment and ellipsis support to json lexer.
@jneen jneen merged commit 077bcd7 into rouge-ruby:master May 19, 2015
@pyrmont pyrmont mentioned this pull request May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants