GithubHelp home page GithubHelp logo

dwhieb / jschemer Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 3.0 1.22 MB

A Node.js library to generate documentation for JSON Schemas

Home Page: https://dwhieb.github.com/jschemer

License: MIT License

JavaScript 38.36% Handlebars 28.81% Less 32.82%
documentation json json-data json-schema schema schemas

jschemer's Introduction

Hello, I'm Danny! πŸ‘‹πŸ» I am a linguist. πŸ—£

I work with the Chitimacha Tribe of Louisiana to help them revitalize their once-dormant language. We are using archival materials to produce a modern dictionary and grammar of the language.

I also run the Digital Linguistics (DLx) project, which provides data formats and web-based tools for working with linguistic data. Check out the DLx developers page or the DLx organization on GitHub.

I am a member of the Algonquian Components Project, a National Science Foundation–funded database of morphological components in Algonquian languages, which uses the Digital Linguistics infrastructure.

dwhieb's github stats Top Languages

Digital Linguistics (DLx) Blog

🌐 Find Me Online! πŸ’» Digital Linguistics (DLx)
πŸ”— my website πŸ”— website
πŸ’¬ Twitter πŸ‘¨πŸΌβ€πŸ’» developers
πŸ“š ResearchGate GitHub
πŸŽ“ Academia.edu πŸ“ blog
πŸ‘¨πŸΌβ€πŸ« Google Scholar πŸ’¬ Twitter
πŸ‘” LinkedIn
0000-0002-1411-3773

jschemer's People

Contributors

alyannalandayan avatar boneskull avatar dependabot[bot] avatar dwhieb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

jschemer's Issues

support command line

index.js contains the conditional statement which determines which action to take.

If run from the command line, run one file (which depends on the non-command line file).

If run as a module, export the non-command line file directly.

What to name each of these?

Add command line tests as well.

copy jschemer.css into out folder

  • create a branch with a descriptive name about what change you're making (see above)
  • write your code! πŸŽ†
  • test your code
  • commit changes
  • sync to github
  • make a pull request

generate index.html

Overview: You'll be writing a function called createIndexPage, which uses the file src/index.hbs as a template, and creates a new file in the out folder called index.html.

Detailed steps are below. Please check off each item once it's done. Don't forget to test your code each step of the way too. If you get stuck or run into trouble on any part, and can't find the answer online, just comment here and I'll reply ASAP.

P.S. As you work through this, spend some time learning more about Atom too. Here's the help documentation for it. Eventually you should read everything in Chapter 2: Using Atom (except for the Version Control section). Keep learning new keyboard shortcuts and using the ones you already know too.

P.P.S. You can click on the links below to take you to the particular sections of code I'm talking about.

P.P.P.S. I created a script that will generate example documentation, so you can use this to test your code. Instead of running jschemer <filename> in node, now you can just run the command npm run example. This will create a folder called example and output the documentation there. So running this command is an easy way to test your code as you go.

Steps to follow:

  • Sync the latest changes from GitHub.

  • Read the GitHub flow guide.

    • We'll be following these steps as we work together on this code. Reading this will help you know what's coming, and understanding why we're doing each step as we do it.
  • Create a new branch called generate-index (because the code you're writing will be generating the index.html page).

    • You'll make all your changes on this branch. When you're done, I'll merge your changes into the master branch. This allows you to make changes without worrying about accidentally breaking code in the master branch.
    • You should sync your changes to this branch frequently as you work. Don't worry if the code isn't working right. That's what branches are for - to mess around with code until you've got it the way you want. Usually, nobody else even looks at your code until it's time to merge your changes into the master branch.
  • Look at the code to understand how your createIndexPage function fits into the larger jschemer function.

  • Use the fs module to read the contents of src/index.hbs.

    • index.hbs contains the template you'll be using in the next step.
  • Compile the template using Handlebars, and save the resulting function to a variable called convert.

Next, you need to tell your convert function what data to use when it converts the template to HTML. In your learning folder, you did this by reading the file called data.json, and passing its contents to convert. This time, instead of reading the data from a file, you're just going to create the data object yourself, and it'll be called context this time instead of data.

  • Create an object called context with 3 properties:

    1. css - Set this equal to the cssPath variable (see here)
    2. nav - Set this equal to the nav variable (see here)
    3. readme - Set this equal to the readme variable, which is passed to your function as an argument (see here)
  • Call the convert function on your context object and save the result to a variable called html.

  • Create a file called index.html in the out folder with html as its contents.

  • Update your generate-index branch with the latest changes from the master branch, then sync your code.

  • Open a pull request to merge your changes into the master branch.

  • Celebrate with your drink of choice 🍷 🍺 🍻 🍸 🍹

Once you've made the pull request, I'll see it and review your code. I'll ask you to make various revisions, then we'll merge your code into the master branch.

create test schema

Go through the entire JSON Schema Draft 07 spec, and create a schema that will test each part of the specification.

issue with `allOf`

The following doesn't render as expected:

    "allOf": [

      { "$ref": "http://cdn.digitallinguistics.io/schemas/Language.json" }
    ]

add styling to landing page

  • Use LESS, and store the LESS file alongside its Handlebars template (create folders for each template, and adjust scripts as needed).

  • The LESS files should compile into a single CSS file for the landing page (a separate, single CSS file will be generated for the schema pages).

  • The CSS file for the landing page should include the CSS for the readme.

index.hbs

This is the main landing page for the generated documentation.

setup Babel

This may not be necessary.

You might need to setup webpack to coordinate Babel and TypeScript.

Update main and bin fields in package.json to use /dist folder.

add base filepath config option

This would allow someone to provide a base filepath, against which relative paths in $ref keywords could be defined. jschemer.js would then need to synchronously read the file at that location, and Object.assign the properties from the local definition onto the external definition, then update the local definition with the external one.

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.