Giter Club home page Giter Club logo

pedestal-docs's Introduction

Pedestal Docs CI

This is an open-source repository of documentation for the Pedestal libraries.

Get Started with Pedestal

Read Pedestal Docs

Contributing

If you wish to point out an issue in the site or propose a new page, you can do so by filing a GitHub issue at https://github.com/pedestal/pedestal/issues

If you wish to make a contribution (typo, modification, or new content), see CONTRIBUTING.md.

Setup

The site is built using Antora.

  • You must have a recent version of NodeJS
  • You need the watchexec command; on OS X: brew install watchexec
  • Finally, a local install of Antora: npm install will download Antora and its dependencies

CAUTION: Working inside NuBank will screw up package-lock.json file, polluting it with references to NuBank's internal repository; package-lock.json has been temporarily added to .gitignore until we work out a better approach.

Building the Site

When building locally, you will need two sibling workspaces: one for this repository, and one for the main Pedestal source.

Retrieve the content:

  • git clone https://github.com/pedestal/pedestal-docs.git (or your own fork)
  • git clone https://github.com/pedestal/pedestal.git (or your own fork)
  • cd pedestal-docs
  • script/local-build.sh

Antora is configured to support diagrams via https://kroki.io/[Kroki]; this involves running a local Docker container to support generation of the diagrams.

Before building the site, you must:

docker compose up -d

This will download the images (they are fairly hefty, so first time will take a while) and start the containers. When you are done with documentation, you should docker compose down.

Full Site Build

To build the full site locally (i.e., the way the GitHub action does):

npx antora --fetch antora-playbook.yml

This will build all versions of Pedestal documentation (currently, the 0.6 and 0.7 versions, from the 0.6-maint and master branches).

Console output will identify the local file URL to load to see the generated site.

This runs once, to completion.

Local Site Build

This approach is used when authoring documentation; you must have the Docker images already running.

script/local-build.sh

This script uses watchexec to monitor the pedestal/docs folders (and others) for changes and (almost instantly!) rebuild the output documentation.

You'll have to manually refresh your browser.

It will also generate desktop notifications when it runs (when on supported platforms).

Pedestal API Documentation

Pedestal API documentation should be updated after each Pedestal release; this is accomplished via the script/gen-api-doc script.

You must have Babashka installed to run this script.

This generates API documentation into the api directory; a subdirectory is created, if necessary, based on the first two terms of the Pedestal version number (e.g., version 0.7.1-alpha-2 would be written to directory api/0.7).

When deploying, the contents of the api directory are merged with the generated content in output.

The api directory is tracked by Git; you should commit and push the changes to ensure that the official CI (Continuous Integration, via a GitHub action) build generates the pedestal.io site using the updated API documentation.

Antora Notes

On OS X, Antora stores Git repos in ~/Library/Caches/antora/ by default.

Be careful to keep antora-playbook.yml and local-antora-playbook.yml in sync.

We are currently using the default Antora UI, with overrides in the ui-overrides directory.

We (at least temporarily) added package-lock.json to .gitignore, as it kept getting filled up with NuBank-specific URLs; this adds some risk that the environment for the GitHub action that does the publishing will drift from local.

Some old directories from the jBake build are still present, such as content, assets, and templates. They are being kept for reference as UI updates to the Antora-generated site continue.

License

Copyright 2014-2024 NuBank NA

The use and distribution terms for this software are covered by the Eclipse Public License 1.0 which can be found in the file epl-v10.html at the root of this distribution.

By using this software in any fashion, you are agreeing to be bound by the terms of this license.

You must not remove this notice, or any other, from this software.

pedestal-docs's People

Contributors

alexanderkiel avatar bpringe avatar christianromney avatar cldwalker avatar cloojure avatar daemianmack avatar dchelimsky avatar ddeaguiar avatar devurandom avatar eckardjf avatar espeed avatar grzm avatar hlship avatar ikitommi avatar julianwegkamp avatar jvtrigueros avatar kevgathuku avatar konrad-garus avatar larrychristensen avatar luskwater avatar mdgart avatar mtnygard avatar mtsbarbosa avatar ohpauleez avatar pdkovacs avatar robertarandolph avatar selimober avatar wilkerlucio avatar yakryder avatar ykomatsu 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  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

pedestal-docs's Issues

Doc issue: clarification of setting :response in an intercepter

I was recently bitten by lack of knowledge, writing an interceptor for a Vase app.

I needed to set the context's :response and then let it be processed by existing Vase code (e.g., converting the response to transit).

I initially did this in the :enter of my interceptor, and was surprised to discover that the remaining interceptors were not called. (The proximate reason is https://github.com/pedestal/pedestal/blob/master/service/src/io/pedestal/http/impl/servlet_interceptor.clj#L373, and I assume that the intention is deliberate).

It was easy to fix my code; I just needed to set the response in my :leave. But, this was not obvious at first, and would be helped by more documentation and examples of how to write interceptors. (Ideally, also with a link to this part of the Pedestal docs from the Vase docs).

Missing tag reference

The document pedestal-docs/content/guides/your-first-api.adoc refers to the tag <4> within tag::list_view[] of pedestal-docs/content/guides/todo-api/src/main.clj, but it is missing, <3> appears again is in its place.

Confusing paragraph about :form-params and keyword-params

#57 cleaned up some confusion about keywordizing in :params (not by default) and :form-params (yes by default, when possible).

Just discovered that http://pedestal.io/reference/parameters still has a confusing paragraph around this:

One catch to note has to do with form parameters from an HTTP POST request. Because form fields can be named just about anything, the keys in these maps aren’t automatically converted to keywords. If you want them to be keywordized, you should make sure to have the keyword-params interceptor on the applicable route.

This is confusing as 1) :form-params (and :query-params) are now by default converted to keywords, when possible and 2) adding keyword-params would also keywordize :params, which by default are not keywordized.

Maybe simply remove this paragraph to avoid further confusion?

Document lein run-dev

The pedestal-service and pedestal-app lein templates set you up to use lein run-dev which lets you see changes without having to reload the repl. Nice feature! The docs don't mention it though.

Maybe there's a better way, but as a newcomer I was exiting the repl and starting it over every time I made a change.

Plans for updating docs, e.g. to cover dataflow v2 ?

I'm finding that this earlier, higher-level Pedestal documentation is a necessary companion to other Pedestal docs, such as app-tutorial. But some parts (text and diagrams) need updating, e.g. to cover the newer dataflow v2. Are there plans to update, and if yes, by when please? Thanks Relevance!

hello-world **java.net.BindException: Address already in use** on server restart

When restarting the server from the boot repl I am getting a java.net.BindException: Address already in use exception on every restart. I end up having to exit boot and get back in.

I am using Ctrl + C to exit the Jetty web server.

Versions:

$ boot -V
#http://boot-clj.com
#Fri Dec 15 15:13:12 MST 2017
BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_CLOJURE_VERSION=1.8.0
BOOT_VERSION=2.7.2

todo-api: potential for the use of list-view and list-item-view to be made uniform

list-view does its work in the :enter phase of the route handling, while list-item-view does it in the :leave phase. This difference entails that these two interceptors are placed in different orders relative to db-interceptor in the "list viewer" and "list-item viewer" routes.

Is there any particular reason for this difference? Is there anything preventing both interceptors from doing their work in, for example, the :leave phase and being uniformly placed before db-interceptor?

Content for the "What is an Interceptor?" guide needs to be written

Topics to cover:

  • Basic structure of :enter, :leave, and :error functions
  • Creating an interceptor from a map
  • Interceptors as values (i.e., def with a map)
  • Interceptors constructed in functions (closing over state)
  • The IntoInterceptor protocol (use a defrecord for an example)
  • Async return from an interceptor
  • Streaming response bodies
  • Distinction between interceptors as a general technique vs. the HTTP handling interceptors in Pedestal

Document Pedestal for speed demons

@ohpauleez has gotten some great performance out of Pedestal apps. We need a guide that shows everyone how to do this.

The "fast-pedestal" sample app is there. Readers could benefit from a walkthrough doc that explains the differences from a default (i.e., template-generated) service.

Paul also has code in a private repo (https://github.com/cognitect-labs/FrameworkBenchmarks-internal/tree/master/frameworks/Clojure/pedestal/src/pedestal) that @mtnygard can use to write a guide.

Add documentation on how to work on Pedestal development

I've found getting started working on Pedestal itself a little bit of a chore. Part of this I believe is due to my inexperience working on libraries, but then again, we want to keep the barrier of entry to contributions as low as possible. Someone who doesn't have a lot of experience but wants to contribute should find it easy to do so.

There are two aspects to this:

  1. Working with unreleased versions of Pedestal in your own projects. Often you find a bug in your project. A fix might be committed but not released. How do you easily test the fix in your project? I use Leiningen in my own projects. Currently I use the Reloaded workflow and lein-test-refresh, both of which have issues when using lein checkouts for Pedestal due to dependencies that can't be loaded. To work around this I use lein install to put SNAPSHOT in my local maven repo. Due to how the Pedestal project is organized, I need to run lein install in each subdirectory. If I'm working with a bunch of different changes independently, this is tedious and error prone. Yes, I should script this. Should we provide a script that does this? Perhaps there's a script that does this already? Maybe some feature of Leiningen I don't know about? How are others handling this? What are some of the best practices?
  2. What are the best practices for developing on Pedestal itself, independent of a particular project? What workflow do the maintainers use? Is there a way of testing the entire project (not just a single subproject)? Are there any automated tools that are useful? For my own projects I've found lein test-refresh useful. Should we consider adding that to the project files for testing?

Stopping and restarting server in the repl

It's not clear following the guide that when running the server in the repl that one should use something like this (def my-server (hello/start)) in order to start the server and then something like (io.pedestal.http/stop my-server) to stop the server. I was confused in the second part of the guide concerning query parameters when it was asked to restart the server (faultily assuming I could just run (hello/start) again) but on attempting this the error appeared java.net.BindException: Address already in use . I had to kill the REPL and restart in order to proceed. On Slack several helpful users (@mavbozo, and @ddeaguiar in the pedestal channel in clojurians pointed out some solutions)

  1. Adding ::http/join? false to the http/create-server function
  2. the (def my-server option)
  3. (alter-var-root #'my-server io.pedestal.http/stop)

Typo in Your First API Guide

With this new helper we can try out a lot of requests from the REPL.
Don't forget to reload the main namespace in the REPL ((require main :reload))
and restart the server ((main/restart)) before you do.

Main needs to be quoted, (require 'main :reload). Also, seems like the double parens could be misinterpreted.

Broken link

The Developing at the REPL link on the guides page, under the interactive development section, is broken. It looks like it is supposed to point to #37, but that page isn't merged yet.

Terse routing describes verb map incorrectly.

The "Quick Reference" says "The value of each key is either a handler function or a list of interceptors." That doesn't seem to work any more. The correct syntax is more like:

{:verb ^{:interceptors [interceptor-1 interceptor-2]} handler}

when only one verb uses the handler, or:

{:verb ^{:interceptors [interceptor-1 interceptor-2]} [:route-name handler]}

when the same handler is used by more than one verb.

Request Map :params isn't necessarily Map of keyword -> String

http://pedestal.io/reference/request-map says that :params is a Map of keyword -> String.
Is this true if one doesn't add keyword-params to the default interceptors?
:params by default seem to use strings for form-params, even if they are keywords in :form-params.

In short, :params by default seems to be a map of keyword or String -> String.

lein new pedestal-service ps
;; verify project.clj is using pedestal.service 0.5.2
in service.clj add handler:
(defn post-test [request] (ring-resp/response request))
and route:
["/test" :post (conj common-interceptors `post-test)]

curl -X POST -d yo=lo localhost:8080/test?any=thing returns:
:params {:any "thing", "yo" "lo"}
:form-params {:yo "lo"}
:query-params {:any "thing"}

references from the 70's should be linked

I am going through the tutorials and am enjoying them. I am sure it will help new people get comfortable with Pedestal.

On
http://pedestal.io/guides/hello-world-query-parameters

Pedestal ginsus that up into a map of parameters for you

As much as that made me chuckle because I was regularly held captive to that commercial as a child, many readers are too young to get the reference or came from outside the US and will not find an entry for the verb "ginsu" at dictionary.com. I recommend adding a link https://www.youtube.com/watch?v=abLB7aTmnE4 to the original commercial or choosing another word. Yeah, 70s, Freedom Rock dude, turn it up!

is the doc updated?..error with (tools-help)

Hi..I'm not sure, but I'm following this documentation, first point: the project.clj is a bit different now, I've preferred dont do changes in this file and keep exactly as the generated by lein new pedestal-service

  1. I run my repl but when I try
    (tools-help)

I get

CompilerException java.lang.RuntimeException: Unable to resolve symbol: tools-help in this context, compiling:(/tmp/form-init7413359724321465815.clj:1:1)

then I try
(use 'io.pedestal.service-tools.dev)

but again I get the same error

and checking the namespace
https://github.com/pedestal/pedestal/blob/master/service-tools/src/io/pedestal/service_tools/dev.clj

I notice than now it's a bit different...and I'm confused...

how is the correct way of start the server (and restart) using repl?

(start) (run-dev) (server/start runnable-service)

ehh..notice than I'm not a clojure expert, I'm a bit newbie so, probably it results obvious to clojure experts but for me is a bit confusing..thank so much

404 Not Found on request to created list in "Your First API" guide

I've copied "the whole shebang" from the end of the Your First API guide and ran the code with leiningen using the dependencies specified at the beginning of the chapter. POSTing a new list with curl (curl -i -X POST localhost:8890/todo?name=mylist) results in a 201 response including a location header. However, trying to then query the new URI (curl -i localhost:8890/id) results in a 404 error.

I've tried to narrow down the source of the error and found that the key ":params" used in the function list-view is not populated with the list-id. The ":path-params" key, however, contains the required value.
Using this to get the list from the database, fails as well, though.
Accessing the database from the REPL (get @database "id") returns nil, although the keys in the database are the list-ids as strings. I've double checked that the keys in the database really are strings, but so far I had no success to get a value from that map.

Maybe I'm missing something obvious here, since I'm fairly new to Clojure. But from my understanding, at least the manual (get ...) to the database should work...

Thanks for your help!

Smooth the learning curve of "Hello World, With Content Types"

During the refactor of the "Hello World, With Content Types", the usage of cond-> seems like a much more significant jump in understanding of Clojure than the rest of the content. I think it would make it much easier to understand if there was some sort of intermediate step to help smooth over what I expect will be a stumbling block for many, especially if they are new to Clojure.

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.