Coder Social home page Coder Social logo

richard1320 / mongoose-docs Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 173 KB

Automatically create documentation for Mongoose schemas.

TypeScript 100.00%
developer-tools mongoose-schema mongoosejs mongoose mongodb document documentation model schema database

mongoose-docs's Introduction

Mongoose Docs

Documentation for your project is very important but also very time-consuming. Programmers often need to leave documentation in the actual code for other developers and then write it again on the frontend for users who don't work with the code.

Mongoose-docs allows you to comment your Mongoose schemas in the codebase and output it in a JSON format that can be rendered on the frontend, so you won't need to copy-paste-copy-paste from your code to a Google Doc.

Generated Documentation

Mongoose Compatability

Mongoose Docs works with Mongoose 5.x and 6.x. However, you need to ensure you are using the correct combination of versions.

Mongoose Version Mongoose-Docs Version
v5.x v1.x
v6.x v2.x

Installation

npm install mongoose-docs --save

Usage

  1. Create your schemas and models. Fields can have a new comment property in the schema type which will be outputted in the JSON.
  2. Execute the mongooseDocsJSON function and pass in mongoose. It will return the analyzed structure in a readable JSON format.
  3. Optional: execute the mongooseDocsOutputHTML function and pass in the result from mongooseDocsJSON and the system directory for the documentation HTML files.

Example

import {mongooseDocsJSON, mongooseDocsOutputHTML} from "mongoose-docs";
import mongoose, {Schema} from "mongoose";

// Your schemas and models
const schemaOptions = {
    timestamps: true,
    comment: "This collection contains all the users.",
};
const userSchema = new Schema({
    email: {
        type: String,
        comment: "This is the user email", // New comment property on schema type
        required: true,
    },
    password: {
        type: String,
        comment: "This is the hashed password", // New comment property on schema type
        required: true,
    },
}, schemaOptions);
mongoose.model('User', userSchema);

// Pass in the Mongoose instance with the models implemented.
const schemaJSON = mongooseDocsJSON(mongoose);

// Optional: Output documentation into HTML files
mongooseDocsOutputHTML(schemaJSON, __dirname + "/docs");

mongoose-docs's People

Contributors

richard1320 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mongoose-docs's Issues

No support for mongoose 7

Hello,

I am trying to install on a project that uses mongoose 7, I get the following:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/mongoose
npm ERR!   mongoose@"^7.0.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer mongoose@"^6.x" from [email protected]
npm ERR! node_modules/mongoose-docs
npm ERR!   mongoose-docs@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/johnkypriotakis/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/johnkypriotakis/.npm/_logs/2023-10-05T16_59_51_943Z-debug-0.log

I assume that means there is no support for mongoose 7 yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.