You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Stefan Klein <st...@gmail.com> on 2013/12/13 16:38:07 UTC

How do you document your document structure?

Hi Couchusers,

all over my javascript source i got statements like
if (doc.field === 'VALUE') {
}
somewhere else:
if (doc.field === 'VALUE2') {
}

what id like to have is something like jsdoc which parses my source and
tells me which fields i use and which values i expect. (Would be easy to
spot typos etc. this way)
I tried jsdoc, created fake classes, it kind of works but is ugly.

Is there a better tool?

thanks,
Stefan

Re: How do you document your document structure?

Posted by Benjamin Young <by...@bigbluehat.com>.
Great work, Travis! I'm eager to see more happen in CouchDB-land around 
the use of JSON-Schema.

FWIW, I'm playing with some MapReduce for identifying content--when you 
don't know what you're getting:
https://github.com/cloudant-labs/Spellbook/tree/master/content-identification

It's sort of the flip-side of having a schema up front...or it could be.

Thanks again for posting this,
Benjamin

On 12/16/13, 10:18 AM, Travis Paul wrote:
> I 2nd JSON schema, it's extremely handy. You can even auto-build your html
> forms with a little extra meta-data. I have an old (possibly outdated)
> example here of using JSON-schema for validation here:
> https://github.com/TravisPaul/couchapp-schema
>
>
> On Mon, Dec 16, 2013 at 10:02 AM, Stefan Klein <st...@gmail.com>wrote:
>
>> 2013/12/13 James Dingwall <ja...@zynstra.com>
>>
>>> Stefan Klein wrote:
>>>
>>>> all over my javascript source i got statements like
>>>> if (doc.field === 'VALUE') {
>>>> }
>>>> somewhere else:
>>>> if (doc.field === 'VALUE2') {
>>>> }
>>>>
>>>> what id like to have is something like jsdoc which parses my source and
>>>> tells me which fields i use and which values i expect. (Would be easy to
>>>> spot typos etc. this way)
>>>> I tried jsdoc, created fake classes, it kind of works but is ugly.
>>>>
>>>> Is there a better tool?
>>>>
>>>   We are using json-schema to document our structure and have imported the
>>> tv4 validator to perform validation tasks within couchdb.  You can use
>>> views to emit documents not conforming to the schema, reject non
>> conforming
>>> documents in validate_doc_update....  The json schema allows us to add
>>> extra metadata around the various fields that say what they are for and
>> we
>>> could pull out such comments when building a ui to edit a document.
>>>
>> Thank you, thats probably a better approach than in-code documentation.
>>


Re: How do you document your document structure?

Posted by Travis Paul <Tr...@visPaul.me>.
I 2nd JSON schema, it's extremely handy. You can even auto-build your html
forms with a little extra meta-data. I have an old (possibly outdated)
example here of using JSON-schema for validation here:
https://github.com/TravisPaul/couchapp-schema


On Mon, Dec 16, 2013 at 10:02 AM, Stefan Klein <st...@gmail.com>wrote:

> 2013/12/13 James Dingwall <ja...@zynstra.com>
>
> > Stefan Klein wrote:
> >
> >> all over my javascript source i got statements like
> >> if (doc.field === 'VALUE') {
> >> }
> >> somewhere else:
> >> if (doc.field === 'VALUE2') {
> >> }
> >>
> >> what id like to have is something like jsdoc which parses my source and
> >> tells me which fields i use and which values i expect. (Would be easy to
> >> spot typos etc. this way)
> >> I tried jsdoc, created fake classes, it kind of works but is ugly.
> >>
> >> Is there a better tool?
> >>
> >  We are using json-schema to document our structure and have imported the
> > tv4 validator to perform validation tasks within couchdb.  You can use
> > views to emit documents not conforming to the schema, reject non
> conforming
> > documents in validate_doc_update....  The json schema allows us to add
> > extra metadata around the various fields that say what they are for and
> we
> > could pull out such comments when building a ui to edit a document.
> >
>
> Thank you, thats probably a better approach than in-code documentation.
>

Re: How do you document your document structure?

Posted by Stefan Klein <st...@gmail.com>.
2013/12/13 James Dingwall <ja...@zynstra.com>

> Stefan Klein wrote:
>
>> all over my javascript source i got statements like
>> if (doc.field === 'VALUE') {
>> }
>> somewhere else:
>> if (doc.field === 'VALUE2') {
>> }
>>
>> what id like to have is something like jsdoc which parses my source and
>> tells me which fields i use and which values i expect. (Would be easy to
>> spot typos etc. this way)
>> I tried jsdoc, created fake classes, it kind of works but is ugly.
>>
>> Is there a better tool?
>>
>  We are using json-schema to document our structure and have imported the
> tv4 validator to perform validation tasks within couchdb.  You can use
> views to emit documents not conforming to the schema, reject non conforming
> documents in validate_doc_update....  The json schema allows us to add
> extra metadata around the various fields that say what they are for and we
> could pull out such comments when building a ui to edit a document.
>

Thank you, thats probably a better approach than in-code documentation.

Re: How do you document your document structure?

Posted by James Dingwall <ja...@zynstra.com>.
Stefan Klein wrote:
> all over my javascript source i got statements like
> if (doc.field === 'VALUE') {
> }
> somewhere else:
> if (doc.field === 'VALUE2') {
> }
>
> what id like to have is something like jsdoc which parses my source and
> tells me which fields i use and which values i expect. (Would be easy to
> spot typos etc. this way)
> I tried jsdoc, created fake classes, it kind of works but is ugly.
>
> Is there a better tool?
  We are using json-schema to document our structure and have imported 
the tv4 validator to perform validation tasks within couchdb.  You can 
use views to emit documents not conforming to the schema, reject non 
conforming documents in validate_doc_update....  The json schema allows 
us to add extra metadata around the various fields that say what they 
are for and we could pull out such comments when building a ui to edit a 
document.

James