Giter Club home page Giter Club logo

docs's Introduction

LFE Documentation Site

Documentation source for Lisp Flavoured Erlang

Contents

Introduction

When I first came here, this was all yak hair. Everyone said I was daft to build a yurt on the Endless High Plain of Yak, but I built in all the same, just to show them. It sank into the Plains of Yak. So I built a second one. That sank into the Plains of Yak. So I built a third. That burned down, fell over, then sank into the Plains of Yak. But the fourth one stayed up. And that's what you're going to get, the strongest yak hair yurt on the Endless High Plain of Yak.

Build for failure? No! Build to burn down, fall over, and sink into the Plains of Yak!

This is the source code that generates the site for the LFE documentation. The last stable release is always available here:

And the current development work on the docs is published here:

Note that the latest dev version provides a drop-down menu in the top-nav for accessing previous releases of the LFE Documentation.

Goals

The aim of this project is twofold:

  • Maintain the content for the LFE documentation site
  • Maintain a tool (written in LFE) for generating the LFE docs site

The next release of the docs site and tooling is v3.1. All tickets for the release are ulimately linked here:

Dependencies

  • Erlang
  • rebar3

If you want to regenerate the CSS, you'll need sass:

  • sass (use make sass to install; requires Ruby + gem to be installed)

Building

There are two supported ways of building the LFE docs site and CSS:

  • using make targets (which call erlang under the hood)
  • running docs functions from the LFE REPL

With make

To (re)generate the static files:

$ make docs-dev

That will build both the HTML files as well as the CSS.

To only build the HTML:

$ make docs-dev-only

To only build the CSS:

$ make css-dev

Additionally, a make target is provided which compiles everything fresh, starts up a local dev HTTP server, and watches for changes in CSS, HTML templates, and LFE code:

$ make serve-dev-watch

The CSS watcher is a backgrounded sass process, and not native LFE, so you will need to kill it when you are done:

$ make css-unwatch

In the REPL

To (re)generate the static files, start up an LFE REPL:

$ make repl
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] ...

   ..-~.~_~---..
  (      \\     )    |   A Lisp-2+ on the Erlang VM
  |`-.._/_\\_.-':    |   Type (help) for usage info.
  |         g |_ \   |
  |        n    | |  |   Docs: http://docs.lfe.io/
  |       a    / /   |   Source: http://github.com/rvirding/lfe
   \     l    |_/    |
    \   r     /      |   LFE v1.3-dev (abort with ^G)
     `-E___.-'

lfe> (docs:start)
ok

To generate the docs to dev:

lfe> (docs-cli:gen-dev)
Created docs/dev/index.html.
...
ok

Or to generate the static files to prod (the current directory; this is only done when promoting dev to stable):

lfe> (docs-cli:gen)
Created docs/current/index.html.
...
ok

To run a local copy of the development server and view your work at http://localhost:8080, run the following:

lfe> (docs-cli:start-httpd)
ok

or for dev server

lfe> (docs-cli:gen-dev-httpd)
ok

The CSS files are managed with sass. After changing values in the priv/sass/lfe*.scss files or in the priv/sass/lfe-sass/ subdirectories, you'll need to rebuild:

$ make css

Contributing Content

This part of the documentation (and code, for that matter) is under very active development and is changing regularly, but as it stands right now, the following steps outline how to add new content to the LFE Documentation site.

Preparation

  1. Fork this repository.
  2. git clone your fork to your local machine and cd to the working directory of your clone. If you will be making CSS changes, you'll need the bootstrap-sass submodule. In that case, you'll want to use git clone --recursive and git clone --recursive --depth 1.
  3. If you plan on making content additions, you'll want to select the template you want to base your page on (e.g., priv/templates/base.html).

Content Creation

  1. Create a new template that extends your selected template, overriding the block with content in your new template (see the other templates for examples of this).
  2. Update the docs-pages:get-page function with a clause that will match your page
    1. If you need a custom data function that sets variables that need to be substituted in your template, be sure to call it here in the get-page function (after you add it to docs-data).
    2. Also, in the get-page function is where you will call your template's render function.
    3. Make sure your get-page code extracts the results of the render function (e.g., using the provided get-content function in the same module).

CSS Updates

  1. Make sure that your clone of lfe/docs has the submodule populated (check the priv/sass/bootstrap-sass/ directory).
  2. Make updates to the file priv/sass/lfe-sass/bootstrap/_theme.scss.
  3. If you need to create some new variables, you'll want to edit priv/sass/lfe-sass/bootstrap/_variables.scss.
  4. Commit your changes to the sass files.
  5. Regenerate the dev CSS with make css-dev.

Generation & Testing

  1. Start up the LFE REPL (e.g., make repl).
  2. Generate the static content with (docs-cli:gen-dev).
  3. Serve the newly generated content with (docs-cli:httpd).
  4. Or do all of those with one target: make serve-dev.
  5. Visit http://localhost:8080/dev/index.html and any other pages you need to test.
  6. Once you are sure it's good, commit the changes.

Caution: Do not run (docs-cli:gen), as that will generate an updated stable version of the docs (the contents of the current) directory. That is only done prior to a new release of LFE and/or the documentation site. Any PRs that update current will not be approved until those changes are removed (modulo typo fixes and the like).

If you have called (docs-cli:gen) by accident, simply do a git checkout of the current dir to undo the docs regen.

Submission

  1. Push to your fork on Github.
  2. Open a PR.

License

Copyright © 2013-2017 LFE Community

Distributed under the Apache License, Version 2.0.

docs's People

Contributors

billota avatar cadar avatar derwolfe avatar doppioslash avatar ericio avatar fhunleth avatar jrdnull avatar kisom avatar macintux avatar mankykitty avatar nazarsh avatar oubiwann avatar prertik avatar rvirding avatar shalokshalom avatar tim avatar

Stargazers

 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docs's Issues

Add lfetool Book

Create a new site book (like the User Guide, the Cookbook, etc.) that does a thorough job explaining how to use (and maximize the use of) lfetool in developing LFE projects of all types.

Add explanatory note at the top of the docs page

We've received some feed back on Twitter about the lack of a good LFE tutorial; that's got a new ticket (issue #40).

While that work is in progress, we need to do some "preventative medicine" by clearly setting expectations (a little of this was done in the README for Casting SPELs in LFE; we need a shorter version of that for our current docs).

So, at the top of the docs site, we need to do the following:

  • Convert the section "Erlang Resources" to "Learning LFE"
  • Add explanatory text saying that, until we have more and better beginners' materials, one needs to learn a bit of Lisp and some Erlang before tackling LFE
  • Provide resources for both, with links
  • Provide a note on "what's next", i.e., once that task has been accomplished, what the reader can do next

Both Quick Starts should have their introductions updated along these lines as well.

Create a basic tutorial for LFE

Based on some recent feedback in Twitter, @rvirding and I are brainstorming about ways in which we can address this lack (both short-term, as well as a more thorough long-term solution). Being a very small open source project with few resources, we have to be very practically minded about this :-) Also, we want to get something out to people as soon as possible, without agonizing over it for a year or two ... so the intended audience would probably be intermediate programmer with minimal experience with Erlang and/or Lisp.

More thoughts on this:

  • this tutorial should mirror a good Erlang tutorial
  • it wouldn't be a comprehensive/detailed tutorial (or workshop?) on LFE
  • rather, it would assume a level of certain knowledge with both Lisps and Erlang itself.

We've created a separate ticket for a comprehensive tutorial (a "phase 2" of the basic tutorial developed in this ticket).

Part of epic #75

Split out LFE function docs

Right now, there's a listing of functions here:

This should be moved to the introductory section, right after the page on data types in LFE.. In its place should be several pages of functions -- description and usage examples for each. What are sections on that page right now should become separate pages.

Create a comprehensive LFE tutorial

Moved to: cnbbooks/catalog#14

Following up on the "Basic Tutorial" in issue #40, this ticket aims to take it to the next level with the following:

  • providing an introduction to Lisps in general for folks that have no background there
  • providing a gentler introduction to Erlang than that provided in the basic tutorial
  • identifying holes or "weak spots" in the Basic Tutorial where new-comers have struggled, encountered ambiguities or difficulties, etc.
  • examining good tutorials from other languages
  • putting all of this together for a v2 of the tutorial

Part of epic #75

Add a section for all data types

This section should go in the introductory chapter, right after the section on loading files. (The listing of functions should come after this, and then the "setting up a dev env" section.)

Show how to get characters from strings, etc., as well.

Identify good examples of API documentation

In the same vein as issue #36 (but with a less immediate need), we should build a list of top-notch programming language, framework, and library docs:

  • what makes them good?
  • how might a given approach be adopted to LFE?
    • how about third-party, community LFE libraries?

Some examples that come to mind:

  • Python: nothing fancy, but rock-solid for nigh two decades
  • OpenStack: Anne Gentle has done an amazing job with this massive, massive project
  • Some bits of the Django docs, since I'm a firm believer in showing code in the docs (though this does introduce a phenomenal maintenance burden, unless you get clever with your docs infrastructure...)
  • I've heard good things about MSDN, but maybe I need more familiarity with it before I see its greatness
  • I hated Amazon's AWS API docs initially, but have grown quite fond of them over the years (and with improvements)

Please share your favourites!

Part of the Planning Epic.

Add "History" section to main docs page

We should have history links for Lisp, Erlang, and LFE. The "LFE" page on http://lfe.io/ has two of the best sources for Lisp; this should be added to a "History" section on the docs main page.

Add the following for Erlang:

Re-style new docs2 site

The copy of the github developer docs site running on docs2.lfe.io is a mess right now, with only partial styling applied. We need to get this fixed up before eyes start bleeding ...

IA and Structure

Tasks:

  • Identify core site areas to highlight on simplified landing page
  • Decide upon top-nav menu items
  • Decide upon bottom-nav menu items
  • Identify major documentation categories
  • For each major category, identify subcategories
  • Identify which categories have content that should be versioned

Our information architecture is basically non-existent. We need to create one.

Part of Milestone v3 #62

Identify good examples of User Guide/Programming book organization

As we begin to iterate on the LFE docs, we need to think about the content we want to present to various types of end user, how that content should be organized, what content is missing from existing docs that would be nice to add, and what content we should remove or rework.

@bigos shared the following link:

And this is a great example of organizing content by experience level. It's not a very common approach, but I like it -- especially for an online resource.

We should also map out the topics covered in:

Then, after compiling that list, we could divide the topics up across one or more levels of experience, as the Haskel wiki book has done...

At any rate, if you have a favorite programming book, please provide a link in the comments and why you liked it, and if you have the time, why you think LFE would benefit from something like that.

Thanks!

Part of the Planning Epic.

Create a docs style guide

This can just start with a sample of all the different things that are styled:

  • terminal code
  • terminal code with emphasis
  • source code
  • code in a paragraph
  • tables
  • alert boxes
  • warning boxes
  • numbered steps/instructions
  • various LFE logos (small grey, small black, small color, large color, etc.)

It would just be a single page showcasing these things (and more), as a reminder to docs maintainers regarding the available styles and the prescribed way to do things.

Part of epic #96

Interop: Java + Elixir

Convert Java Interop section to just "Interop" -- include Elixir and Joxa interop examples?

Backquote macro in LFE

This is from an email that Robert sent, and it's a great idea:

I was looking through some of the examples you refer to in the LFE page when I remembered that LFEs backquote macro even works with tuples . So you can use a tuple "pattern" which expands into code to build a tuple. For example:

`#(ok ,reply) ==> (tuple 'ok reply))

With that you could write the callbacks to the ping_pong server as:

(defun init (args)
  `#(ok ,(make-state pings 0)))

(defun handle_call (req from state)
  (let* ((new-count (+ (state-pings state) 1))
         (new-state (set-state-pings state new-count)))
    `#(reply #(pong ,new-count) ,new-state)))

It of course also works in patterns. This is clearer and more concise for those who know about it but I don't think that this is something to drop on the poor unsuspecting reader from the beginning, but a section on the backquote macro would be good to have somewhere.

Create some versioned docs using docs2

To figure out of the Github Documentation example site will work for LFE's versioned docs, a couple of example uses are needed. This will help determine if the Github approach will suit our needs. If so, this will allow us to close issue #38 :-)

To accomplish this:

  • use the LFE user_guide.txt for the v0.6, v0.8, v0.9, and v0.9.1 releases
  • identify the workflow necessary to create a versioned part of the site
  • use that to create 4 versioned "areas", one for each of the above
  • identify weak spots, difficulties, etc.

Add record matching in function heads in pattern matching section

Moved to: cnbbooks/lfe-manual#29

This page:

Example Erlang code:

handle_info(ping, #state {remote_pid = undefined} = State) ->
    gen_server:cast(self(), ping),
    {noreply, State};

handle_info(ping, State) ->
    {noreply, State};

handle_info({pong, Pid}, #state {remote_pid = undefined,
                                 waiters = Waiters} = State) ->
    ?INFO("connection to java node established, pid ~p", [Pid]),
    link(Pid),
    lists:foreach(fun(Waiter) ->
                          gen_server:cast(self(), {wait_for_login, Waiter})
                  end, Waiters),
    {noreply, State#state {waiters = [],
                           remote_pid = Pid}};

handle_info({pong, _}, State) ->
    {noreply, State};

handle_info({Port, {exit_status, Status}}, #state {ext_port_ref = Port} = State) ->
    ?ERROR("external java app exited with status ~p", [Status]),
    {stop, {error, {java_app_exit, Status}}, State};

handle_info({'EXIT', Pid, Reason}, #state {remote_pid = Pid} = State) ->
    ?ERROR("external java mbox exited with reason ~p", [Reason]),
    {stop, {error, {java_mbox_exit, Reason}}, State};

handle_info(_Info, State) ->
    ?ERROR("unhandled info, ~p", [_Info]),
    {noreply, State}.

Corresponding LFE code:

(defun handle_info
  (('ping (= (match-state remote-pid 'undefined) state))
    `#(noreply ,state))
  (('ping state)
   `#(noreply ,state))
  (((tuple 'pong pid) (= (match-state remote-pid 'undefined
                                      waiters waiters)
                         state))
   (INFO "Connection to java node established, pid: '~p'" (list pid))
   (link pid)
   (lists:foreach
     (lambda (x)
       (gen_server:cast (self) `#(wait-for-login x)))
     waiters)
   `#(noreply ,(make-state remote-pid pid
                           waiters waiters
                           ext-port-ref (state-ext-port-ref))))
  (((tuple 'pong _) state)
   `#(noreply ,state))
  (((tuple port (tuple 'exit-status status)) (= (match-state ext-port-ref ext-port)
                                                state)) (when (== port ext-port))
   (ERROR "External java app exited with status: '~p'" (list status))
   `#(stop #(error #(java-app-exit ,status)) ,state))
  (((tuple 'EXIT pid reason) (= (match-state remote-pid remote-pid)
                                state)) (when (== pid remote-pid))
   (ERROR "External java mbox exited with reason: '~p'" (list reason))
   `#(stop #(error #(java-mbox-exit ,reason)) ,state))
  ((info state)
   (ERROR "Unhandled info: '~p'" (list info))
   `#(noreply ,state)))

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.