Giter VIP home page Giter VIP logo

crodoc's Introduction

crodoc

crodoc is a documentation tool for the Crystal programming language meant to be a replacement for the built in documenter. The goal of crodoc is to be a more powerful and extensible way to document your code, with support for meta-data tags, plugins, custom templates, and more.

Features

Meta-data Tags

Meta-data tags are used to add arbitrary meta-data about a documented object. These tags simply add data to objects that can be looked up later, and potentially displayed. The nice thing about meta-data tags is that they allow you to organize your comments easily and systematically, and allow exporters to easily glean important information about your code. Let's look at an code example using Crystal's documenter:

# Example from watzon/octokit.cr

# Check if you is following a user. Alternatively check if a given user
# is following a target user.
#
# **Examples:**
# ```
# @client.follows?("asterite")
# @client.follows?("asterite", "waj")
# ```
#
# **Note:** Requires an authenticated user.
#
# **See Also:**
# - [https://developer.github.com/v3/...](https://developer.github.com/v3/...)
# - [https://developer.github.com/v3/...](https://developer.github.com/v3/...)
def follows?(user, target = nil)
  ...
end

Because the Crystal documenter only supports markdown I had to manually create sections for Examples, Notes, and See Also. Crystal does have limited support for certain items like NOTE, DEPRECATED, etc. but there aren't many options. Now let's looks at a (proposed) example for crodoc.

# Check if you is following a user. Alternatively check if a given user
# is following a target user.
#
# @note Requires an authenticated user.
# @see https://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user]
# @see https://developer.github.com/v3/users/followers/#check-if-one-user-follows-another
# @example
#   @client.follows?("asterite")
#   @client.follows?("asterite", "waj")
def follows?(user, target = nil)
  ...
end

Not only is it 7 less lines, It's also easier to type and easier to parse. Meta-data tags can do just about anything as well.

Plugins

With plugins crodoc becomes so much more than just a documentation generator. Plugins can do things like add meta-data tags, generators, parsers, etc.

Custom Templates

Currently there is only one available way to view your Crystal documentation, and (objectively) it isn't great. Personally I don't like being locked into a specific style of doing things. As such with crodoc you can choose a custom template with which to render your documentation. This is an option that YARD provides, and the Crystal community deserves it too.

Installation

You can install crodoc in three ways:

Using CURL

To install with CURL (the easiest method) run the following in your terminal:

curl -L https://git.io/fj4sg | bash

and let it install. If you wish to inspect the installer script just check it out here.

Clone the Repo

You can always build this from sources. The installer does this anyway if a binary isn't avaialable for your system.

git clone https://github.com/watzon/crodoc.git
cd crodoc
crystal build ./src/crodoc.cr --release

When building from sources you will have to manually move the binary so that it's on your path.

Add to Your Project

You can also add crodoc locally to your project. Doing this will build a binary in the root of your project, allowing you to run it with ./crodoc.

# shard.yml

development_dependencies:
  crodoc:
    github: watzon/crodoc

Don't forget to run shards install after adding it to your shard.yml.

Usage

TODO: Write usage instructions here

Contributing

  1. Fork it (https://github.com/watzon/crodoc/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

crodoc's People

Contributors

watzon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

crodoc's Issues

Some questions

I find yard way better than rdoc and use it for all my ruby programs and I find default crystal documentation system very basic, so that's only natural I found about crodoc.

I have several questions :

  1. Does crodoc supports @param, @option, @return like Yard? (I see none in examples)
  2. Could you document what are all the keywords supported?
  3. Could you build crodoc documentation using crodoc and host it on github pages so we could have a live demo?
  4. Does it work with Crystal 1.7?
  5. Do you still plan to maintain it or should I consider it abandoned?
  6. How to use it? The section is blank https://github.com/watzon/crodoc#usage, it doesn't override crystal docs it it must use it's own command.

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.