GithubHelp home page GithubHelp logo

reactioncommerce / redoc Goto Github PK

View Code? Open in Web Editor NEW
20.0 26.0 11.0 3.89 MB

redoc - generate documentation from multiple project repos.

License: GNU General Public License v3.0

HTML 36.66% JavaScript 22.77% CSS 40.37% Shell 0.19%
redoc documentation markdown meteor javascript

redoc's Introduction

redoc

Circle CI Code Climate

redoc is a Meteor application that can be used to present styled markdown from multiple Github repositories.

redoc fetches content from GitHub and renders markdown, caching the HTML to be managed with a Table of Contents and stylized with theme packages.

git clone https://github.com/reactioncommerce/redoc.git
cd redoc && npm install
meteor --settings settings.json

To run tests:

npm run test - run unit tests npm run test-app - run "full app" tests npm run chimp run browser tests (while app running) npm run chimp-watch run browser tests in watch mode (while app running)

redoc is the application used for the Reaction documentation.

redoc is using meteor 1.3, with imported npm dependencies. It also uses react and react-router to render HTML server-side for the docs.

Since we use this project to generate docs for Reaction Commerce, we've included our settings.json and redoc.json that we use to generate our documentation as an example.

Initialization

redoc is initialized with an array of repositories repos, and a Table of Contents, tocData array. These are defined in settings.json redoc.initRepoData.

settings.json example

{
  "public": {
    "ga": {
      "account": ""
    },
    "gitter": {
      "room": "reactioncommerce/reaction"
    },
    "redoc": {
      "branch": "master",
      "publicBranches": [
        "master"
      ]
    }
  },
  "services": [{
    "github": {
      "clientId": "",
      "secret": "",
      "webhook": {
        "updateDocs": ""
      }
    }
  }],
  "redoc": {
    "users": [
      {
        "username": "github_username",
        "roles": ["admin"]
      }
    ],
    "initRepoData": {
      "repos": [{
        "org": "reactioncommerce",
        "repo": "reaction-docs",
        "label": "Reaction",
        "description": "Reaction Commerce Guide"
      }],
      "tocData": [{
        "class": "guide-nav-item",
        "alias": "intro",
        "label": "Introduction",
        "repo": "reaction-docs",
        "docPath": "index.md",
        "default": true
      }, {
        "class": "guide-sub-nav-item",
        "alias": "dashboard",
        "label": "Dashboard",
        "repo": "reaction-docs",
        "docPath": "admin/dashboard.md"
      }]
    }
  }
}

Document Structure

Documents is split into one of two sides. Left - Explanation Right - Examples

Heading levels (h1, h2, h3) create distinct sections. Heading level (h4) does not create a section, instead lives in the current heading section. Heading levels (h5, h6) create an example sub section within the current heading section.

The following example shows how this works:

# h1 - (creates a section)
Introduction Content

##### h5 - (starts the example section for the h1)
Example Content
Example ends at the h2. h2 is a new section

## h2 - (creates a section)
Content for h2

##### h5 - (starts the example section for the h2)
Example Content
Example ends at the h3. h3 is a new section

### h3 - (creates a section)
Content for h3

#### h4
#### h4
#### h4

##### h5 - (starts the example section for the h3, h4's are not distinct sections)
code
paragraph
table
list
etc...

###### h6 - (same effect as h5)
content...
Example ends at the h3. h3 is a new section

### h3
Content for h3
Has no example content. The right hand side will be empty, and thats OK.

The environment variable METEOR_SETTINGS can also be used.

Remote configuration

You can supply a url in initRepoData as well, and we'll fetch from the remote location.

"redoc": {
  "initRepoData": "https://raw.githubusercontent.com/reactioncommerce/redoc/master/private/redoc.json"
}

initRepoData can also be an object defining the initRepoData.

TOC Example Data

{
  "repos": [{
    "org": "reactioncommerce",
    "repo": "reaction-docs",
    "label": "Reaction",
    "description": "Reaction Commerce Guide"
  }, {
    "org": "reactioncommerce",
    "class": "guide-sub-nav-item",
    "repo": "reaction-braintree",
    "label": "Braintree",
    "docPath": "README.md"
  }, {
    "class": "guide-sub-nav-item",
    "org": "reactioncommerce",
    "repo": "reaction-paypal",
    "label": "Paypal",
    "docPath": "README.md"
  }
}

If you supply only a repo, the TOC data will be generated from the repo's folder/file structure.

Theme

To customize the theme, copy the packages/reaction-doc-theme to a new package folder, and update the packages.js with your new theme package name.

Gitter

Use Meteor.settings.public.gitter.room to configure the Gitter Sidecar room. To remove Gitter:

meteor remove reactioncommerce:redoc-gitter

Scheduling

Meteor.settings.redoc.schedule is configurable in settings.json, and defaults to "every 4 hours".

This configures a schedule for flushing the collections and fetching updates.

Deployment

Although you can deploy Redoc with any of the deployment methods supported by Meteor, the recommended method is to use Docker. Redoc has several Dockerfiles to choose from that are intended for different use cases.

All Dockerfiles and the associated build scripts are in the docker/ directory. The default Dockerfile in the root of the project is an alias that points to docker/redoc.prod.docker (which is the recommended Dockerfile for production deployments). However, the production image builds from a base OS from scratch every time and will take a bit longer to build than the development image (found at docker/redoc.dev.docker). So when you're developing locally, you may prefer to have the faster build time that the development image gives you (by caching each build step layer). Just note that you don't ever want to use the development image for production because the image size is usually about 4x the size of the production image.

Build

The Docker build step is optional and is only required if you have a customized version of Redoc. If you haven't customized the app, skip to the next section.

To build your custom version of Redoc:

# production image
docker build -t <your org>/redoc .

# or a local development image for quicker debugging
docker build -f docker/redoc.dev.docker -t <your org>/redoc .

Once you have built a production image, you can push it to your Docker Hub account:

docker push <your org>/redoc

Run

Running the official Redoc image (assuming you're using settings.json in the project root and an external MongoDB):

docker run -d \
  -p 80:80 \
  -e ROOT_URL='http://example.com' \
  -e MONGO_URL='mongodb://url...' \
  -e METEOR_SETTINGS='$(cat settings.json)' \
  reactioncommerce/redoc:latest

We've also provided an example Docker Compose config (docker-compose.yml) that can be used as a starting point if you'd like to use the official MongoDB image from Docker Hub.

redoc:
  image: reactioncommerce/redoc:latest
  ports:
    - 80:80
  links:
    - mongo
  restart: always
  environment:
    ROOT_URL: "http://example.com" # set to your domain name
    MONGO_URL: "mongodb://mongo:27017/redoc" # this is fine as-is
    METEOR_SETTINGS: # provide a JSON stringified version of your settings.json here

mongo:
  image: mongo:latest
  restart: always
  command: mongod --storageEngine=wiredTiger

Once you've added your METEOR_SETTINGS, you can then run start up the containers with:

docker-compose up -d

Once the containers have started, your app should be linked to the mongo container and serving content on port 80.

redoc's People

Contributors

jshimko avatar kieckhafer avatar marceloschmidt avatar mikemurray avatar zenweasel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redoc's Issues

Autoscroll

Autoscroll documents as you scroll down the docs/ TOC. Load next document in the order of the TOC when you reach bottom of page.

Update to latest Meteor

Quick test caused recurring crash, so this needs a little investigation.

W20170503-11:18:19.900(-7)? (STDERR) Error: failed [404] 404: Not Found
W20170503-11:18:19.900(-7)? (STDERR)     at Object.Future.wait (/Users/aaronjudd/.meteor/packages/meteor-tool/.1.4.4_2.1165hub++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:449:15)

Building On Local gives error on Both Win7 and Ubuntu environment.

Please see the Error Log Below.

Error: Can't find npm module 'classnames'. Did you forget to call 'Npm.depends' in package.js within
at Object.Npm.require (D:\Devprojects\docs.meteor\local\build\programs\server\boot.js:175:17)
at options.fallback (packages/modules/modules.js:20:1)
at require (packages/modules/.npm/package/node_modules/install/install.js:79:1)
at meteorInstall.app.common.docs.toc.jsx (common/docs/toc.jsx:3:56)
at fileEvaluate (packages/modules/.npm/package/node_modules/install/install.js:183:1)
at require (packages/modules/.npm/package/node_modules/install/install.js:75:1)
at meteorInstall.app.common.docs.docs.jsx (common/docs/docs.jsx:2:40)
at fileEvaluate (packages/modules/.npm/package/node_modules/install/install.js:183:1)
at require (packages/modules/.npm/package/node_modules/install/install.js:75:1)
at D:\Devprojects\docs.meteor\local\build\programs\server\app\app.js:1507:1

Navigation broken in redoc

Navigation is not working. Follows the github button install. Didn't see this locally. Maybe needs to be added to browser-policy?

    at https://buttons.github.io/buttons.js:1:5312
    at HTMLIFrameElement.a (https://buttons.github.io/buttons.js:1:934)```

SyncedCron: Exception "Update Repo Cache"

Console error appearing as a result of Update Repo Cache cron job:

Appears when job runs.

    at Object.Future.wait (/Users/aaronjudd/.meteor/packages/meteor-tool/.1.4.2_3.1rd9djy++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:449:15)
    at MongoConnection.<anonymous> (packages/meteor.js:213:24)
    at MongoConnection.(anonymous function) [as update] (packages/mongo/mongo_driver.js:774:49)
    at [object Object].update (packages/mongo/collection.js:589:29)
    at [object Object].Mongo.Collection.(anonymous function) [as update] (packages/aldeed_collection2-core.js:232:19)
    at [object Object].upsert (packages/mongo/collection.js:676:15)
    at updateRepoData (packages/reactioncommerce:redoc-co```

Switching branches before selecting a subheader gives an error

Steps to reproduce:

  1. Navigate to the root (i.e. /) and do not select a subsection
  2. Select a different branch from the dropdown
  3. Observe that "Requested document not found for this version." is shown and the url contains "undefined"

Once you select a subsection, everything works as expected.

A failing acceptance test is included in PR

Collapsible, responsive sidebar

Update sidebar to collapse "guide-sub-nav-items" into "guide-nav-items.".

Update with responsive / hamburger menu for mobile.

Move main code into packages for reusability

We are starting to use REDOC for the Rocket.Chat documentation. Awesome work!

What do you guys think about following Telescope approach and moving the core code into packages, or just a big package that can be added into other projects?

Your application is crashing

I was trying to do meteor --settings settings.json and I got the following error messages:

I20170118-10:22:06.416(8) (percolate_synced-cron.js:87) SyncedCron: Scheduled "Update Repo Cache" next run @Wed Jan 18 2017 12:00:00 GMT+0800 (CST)
I20170118-10:22:06.419(8) (percolate_synced-cron.js:87) SyncedCron: Scheduled "Flush Docs Cache" next run @Wed Jan 18 2017 12:00:00 GMT+0800 (CST)
W20170118-10:22:06.915(8)? (STDERR) /Users/username/.meteor/packages/meteor-tool/.1.4.2_3.1rd9djy++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:313
W20170118-10:22:06.916(8)? (STDERR)             throw(ex);
W20170118-10:22:06.916(8)? (STDERR)             ^
W20170118-10:22:06.917(8)? (STDERR) 
W20170118-10:22:06.917(8)? (STDERR) Error: failed [404] 404: Not Found 
W20170118-10:22:06.917(8)? (STDERR)     at Object.Future.wait (/Users/username/.meteor/packages/meteor-tool/.1.4.2_3.1rd9djy++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:449:15)
W20170118-10:22:06.918(8)? (STDERR)     at Object.call (packages/meteor.js:213:24)
W20170118-10:22:06.918(8)? (STDERR)     at Object.HTTP.get (packages/http/httpcall_common.js:50:20)
W20170118-10:22:06.918(8)? (STDERR)     at getRepoData (packages/reactioncommerce:redoc-core/server/methods/repoData.js:82:35)
W20170118-10:22:06.919(8)? (STDERR)     at updateRepoData (packages/reactioncommerce:redoc-core/server/methods/repoData.js:108:22)
W20170118-10:22:06.919(8)? (STDERR)     at packages/reactioncommerce:redoc-core/server/startup.js:54:3
W20170118-10:22:06.919(8)? (STDERR)     at Function.time (/Users/username/Desktop/redoc/.meteor/local/build/programs/server/profile.js:301:28)
W20170118-10:22:06.919(8)? (STDERR)     at /Users/username/Desktop/redoc/.meteor/local/build/programs/server/boot.js:304:13
W20170118-10:22:06.920(8)? (STDERR)     at /Users/username/Desktop/redoc/.meteor/local/build/programs/server/boot.js:345:5
W20170118-10:22:06.920(8)? (STDERR)     at Function.run (/Users/username/Desktop/redoc/.meteor/local/build/programs/server/profile.js:480:12)
W20170118-10:22:06.920(8)? (STDERR)     - - - - -
W20170118-10:22:06.920(8)? (STDERR)     at makeErrorByStatus (packages/http/httpcall_common.js:13:10)
W20170118-10:22:06.921(8)? (STDERR)     at Request._callback (packages/http/httpcall_server.js:113:17)
W20170118-10:22:06.921(8)? (STDERR)     at Request.self.callback (/Users/username/.meteor/packages/http/.1.2.10.3yb3pj++os+web.browser+web.cordova/npm/node_modules/request/request.js:200:22)
W20170118-10:22:06.921(8)? (STDERR)     at emitTwo (events.js:87:13)
W20170118-10:22:06.922(8)? (STDERR)     at Request.emit (events.js:172:7)
W20170118-10:22:06.922(8)? (STDERR)     at Request.<anonymous> (/Users/username/.meteor/packages/http/.1.2.10.3yb3pj++os+web.browser+web.cordova/npm/node_modules/request/request.js:1067:10)
W20170118-10:22:06.923(8)? (STDERR)     at emitOne (events.js:82:20)
W20170118-10:22:06.923(8)? (STDERR)     at Request.emit (events.js:169:7)
W20170118-10:22:06.923(8)? (STDERR)     at IncomingMessage.<anonymous> (/Users/username/.meteor/packages/http/.1.2.10.3yb3pj++os+web.browser+web.cordova/npm/node_modules/request/request.js:988:12)
W20170118-10:22:06.924(8)? (STDERR)     at emitNone (events.js:72:20)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.

I was wondering if there's anything that I did wrong? Thanks.

Doc Search

Search docs, using Docs.alias as auto-complete prompt. Search full text of Docs.pageContentData.
Dropdown with results, click dropdown result go to page.

Extra line-breaks being added

I can't figure out exactly why this is happening and not other places. But this line of markdown

## Removing Products
To remove an entire product, login as a user with sufficient permissions, and click the Delete icon in     the grid view. To remove an individual variant, see the Product Variant section below.

Is displaying like this:
reaction_docs_-_product_management

Updates and enhancements

  • Updated to latest meteor 1.3 beta
  • Restructure app to mirror suggested application structure
  • Add 3rd level to TOC
  • Add an "edit this on github" link to each doc
  • Update styles: Typography
  • Update styles: Condense width of content area to help with readability
  • Update styles: Increase width of sidebar to make it feel less cramped and support a 3rd level
  • Accounts: Sign in with github
  • Accounts: Simple admin page or button to refresh the doc cache (admins only)

TOC Admin UI

Insert, delete, reorder TOC from admin UI.

  • add accounts, accounts-base
  • add sortable, position property to TOC (or just use array order?)
  • add discrete login link to docs
  • add default admin user
  • do not use "/admin" or anthing so obvious, so allow for docs "admin",.suggest "redoc/admin"
  • visibility / publish / unpublish
  • flushDocCache / refresh element

default docs should load from redoc

on a fresh install where no settings are supplied the defaults should load toc,etc from redoc, it used to do this but is now defaulting to reaction-doc. see: packages/redoc-core/lib/startup.js

Search results list all hits twice

When you do a search and look through the result you get al the matching entries and then basically it starts over and shows them all again. Not a huge deal but worth fixing.

header template method

a header method to inject a remote header template and data to be rendered locally. This should be possible with DDP.connect . The goal would be that Meteor sites could have a continuous flow when integrated in another Meteor site, and redoc itself wouldn't need customization.

search result highlights break image links

using "products", and viewing console you'll see breaking links. We need to tweak the regex replace a little.

The search function will highlight the search term with a , and will also add that to URLs:

image

screen shot 2018-01-26 at 2 35 35 pm
image

Broken link in email search results

Search the docs using the keyword 'email' the search results will include an item titled: "An Introduction to Architecture: Alerts, Notifications & Emails" which leads to a 404 :(

local path link handling

local path links are not working in many of our documents. We need to document/explain/fix this strategy to get all our local paths working.

The problem:

We're currently seeing failing links like:

https://docs.reactioncommerce.com/reaction-docs/development/configuration.md

a working version of this link is:

https://docs.reactioncommerce.com/reaction-docs/development/configuration

It seems to work when the last segment in the path matches the last segment of a docPath defined in redoc.json.

Github stars obscured in header

This might be a dupe of #81 but it's hard to tell as that issue is a little vague.

No matter how wide you make it they are still obscured.

2017-12-08_05-59-01

Defining ROOT_URL with a subfolder

We defined ROOT_URL as a subfolder (eg. http://localhost:3000/docs).
If we didn't touch the code, it would just not work at all. Server would render correctly, but then client would re-render a blank page. Any thoughts on how to fix that?
We went ahead and made a few changes to the code, so now it works on a subfolder, but it has it's drawbacks. First, we had to include a meta tag, and now all links have to be relative instead of absolute. Second, although clicking a menu link will open the right URL, if you inspect the link, you'll notice that it points to what would be an invalid location, i.e., without the /docs, and so search engine crawlers wouldn't be able to crawl our page. Do you have a walkthrough on how to run this on a subfolder? TIA

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.