Skip to content

Raw sassdoc data is not valid JSON #181

Description

@alademann

@hugogiraudel According to this section in the readme, the raw data is made available.

However - I am unable to easily create a JSON file out of this, because the output is not valid JSON. Some key values are single-quoted, some have no quotes at all.

For instance - nothing happens when I try this:

sassdoc.parse('./sass').then(function (items) {
    console.log(JSON.stringify(items));
});

And the raw data itself - looks like this: (Which even the syntax highlighter github is using recognizes as invalid JSON)

{ 
    variable: { 
        'breakpoint-no-query-fallbacks': { 
            description: '',
            context: [Object],
            type: [Object],
            since: [Object],
            requires: [Object],
            link: [Object],
            access: [Object],
            group: [Object],
            file: [Object] 
        },
        'font-size-xs': { 
            description: '',
            context: [Object],
            type: [Object],
            since: [Object],
            requires: [Object],
            access: [Object],
            group: [Object],
            file: [Object] 
        },
        modules: { 
            description: '',
            context: [Object],
            ignore: [],
            access: [Object],
            group: [Object],
            file: [Object] 
        } 
    },
    mixin: { 
        'triangle-direction': { 
            description: '...',
            context: [Object],
            since: [Object],
            requires: [Object],
            parameters: [Object],
            throws: [Object],
            access: [Object],
            group: [Object],
            file: [Object],
            usedBy: [Object] 
        },
        triangles: { 
            description: '...',
            context: [Object],
            since: [Object],
            requires: [Object],
            parameters: [Object],
            access: [Object],
            group: [Object],
            file: [Object] 
        },
        'btn-reset': { 
            description: '...',
            context: [Object],
            since: [Object],
            requires: [Object],
            access: [Object],
            group: [Object],
            file: [Object],
            usedBy: [Object] 
        },
        'hide-text': { 
            description: '...',
            context: [Object],
            since: [Object],
            access: [Object],
            group: [Object],
            file: [Object] 
        } 
    },
    function: { 
        color: { 
            description: '...',
            context: [Object],
            access: [Object],
            since: [Object],
            requires: [Object],
            parameters: [Object],
            returns: [Object],
            group: [Object],
            file: [Object],
            usedBy: [Object] 
        },
        'state-variation-text': { 
            description: '...',
            context: [Object],
            since: [Object],
            requires: [Object],
            parameters: [Object],
            throws: [Object],
            returns: [Object],
            access: [Object],
            group: [Object],
            file: [Object] 
        } 
    } 
}

Note that keys containing - are quoted (using single quotes) - and those that do not have dashes, have no quotes. (It all should be double-quoted for valid JSON). I'm not sure if there are other reasons why the JSON is invalid, possibly quotes within the descriptions / other fields or something... but at a minimum, I would expect the raw data to return the ACTUAL objects within objects - not [Object].

As a consumer, I shouldn't have to write my own parser for the parser :)

Activity

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions