Skip to content

Commit

Permalink
Fix markdown issues (phoenixframework#4972)
Browse files Browse the repository at this point in the history
  • Loading branch information
kianmeng authored Sep 24, 2022
1 parent b1efc79 commit 64ab574
Show file tree
Hide file tree
Showing 19 changed files with 78 additions and 69 deletions.
12 changes: 7 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ making it easier for developers to [contribute to Phoenix](#pull-requests).
## Bug reports

A bug is either a _demonstrable problem_ that is caused by the code in the repository,
or indicate missing, unclear, or misleading documentation. Good bug reports are extremely
or indicate missing, unclear, or misleading documentation. Good bug reports are extremely
helpful - thank you!

Guidelines for bug reports:
Expand Down Expand Up @@ -134,8 +134,10 @@ in order to craft an excellent pull request:
```bash
# Clone your fork of the repo into the current directory
git clone https://github.com/<your-username>/phoenix

# Navigate to the newly cloned directory
cd phoenix

# Assign the original repo to a remote called "upstream"
git remote add upstream https://github.com/phoenixframework/phoenix
```
Expand Down Expand Up @@ -216,10 +218,10 @@ complete, the better.

For formatting the guides:

- We use the "elixir" code fence for all module code.
- We use the "iex" for IEx sessions.
- We use the "console" code fence for shell commands.
- We use the "html" code fence for html templates, even if there is elixir code
- We use the `elixir` code fence for all module code.
- We use the `iex` for IEx sessions.
- We use the `console` code fence for shell commands.
- We use the `html` code fence for html templates, even if there is elixir code
in the template.
- We use backticks for filenames and directory paths.
- We use backticks for module names, function names, and variable names.
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
![phoenix logo](https://raw.githubusercontent.com/phoenixframework/phoenix/master/priv/static/phoenix.png)

> Peace of mind from prototype to production.
[![Build Status](https://github.com/phoenixframework/phoenix/workflows/CI/badge.svg)](https://github.com/phoenixframework/phoenix/actions/workflows/ci.yml) [![Hex.pm](https://img.shields.io/hexpm/v/phoenix.svg)](https://hex.pm/packages/phoenix) [![Documentation](https://img.shields.io/badge/documentation-gray)](https://hexdocs.pm/phoenix)

## Getting started

See the official site at https://www.phoenixframework.org/
See the official site at <https://www.phoenixframework.org/>.

Install the latest version of Phoenix by following the instructions at https://hexdocs.pm/phoenix/installation.html#phoenix
Install the latest version of Phoenix by following the instructions at <https://hexdocs.pm/phoenix/installation.html#phoenix>.

## Documentation

API documentation is available at [https://hexdocs.pm/phoenix](https://hexdocs.pm/phoenix)
API documentation is available at <https://hexdocs.pm/phoenix>.

Phoenix.js documentation is available at [https://hexdocs.pm/phoenix/js](https://hexdocs.pm/phoenix/js)
Phoenix.js documentation is available at <https://hexdocs.pm/phoenix/js>.

## Contributing

Expand All @@ -28,8 +29,8 @@ You can create a new project using the latest Phoenix source installer (the `phx
3. Run the `phx.new` Mix task from within the `installer` directory, for example:

```bash
$ cd phoenix/installer
$ mix phx.new dev_app --dev
cd phoenix/installer
mix phx.new dev_app --dev
```

The `--dev` flag will configure your new project's `:phoenix` dep as a relative path dependency, pointing to your local Phoenix checkout:
Expand All @@ -44,30 +45,30 @@ To create projects outside of the `installer/` directory, add the latest archive
To build the documentation from source:

```bash
$ npm install --prefix assets
$ MIX_ENV=docs mix docs
npm install --prefix assets
MIX_ENV=docs mix docs
```

To build Phoenix from source:

```bash
$ mix deps.get
$ mix compile
mix deps.get
mix compile
```

To build the Phoenix installer from source:

```bash
$ mix deps.get
$ mix compile
$ mix archive.build
mix deps.get
mix compile
mix archive.build
```

### Building phoenix.js

```bash
$ cd assets
$ npm install
cd assets
npm install
```

## Important links
Expand Down
12 changes: 8 additions & 4 deletions guides/asset_management.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ Finally, all other assets, that usually don't have to be preprocessed, go direct

If you want to import JavaScript dependencies, you have two options to add them to your application:

1. Vendor those dependencies inside your project and import them in your "assets/js/app.js" using a relative path:
1. Vendor those dependencies inside your project and import them in your "assets/js/app.js" using a relative path:

import topbar from "../vendor/topbar"
```js
import topbar from "../vendor/topbar"
```

2. Call `npm install topbar --save` inside your assets directory and `esbuild` will be able to automatically pick them up:
2. Call `npm install topbar --save` inside your assets directory and `esbuild` will be able to automatically pick them up:

import topbar from "topbar"
```js
import topbar from "topbar"
```

## CSS

Expand Down
15 changes: 6 additions & 9 deletions guides/contexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ $ mix ecto.migrate

Before we jump into the generated code, let's start the server with `mix phx.server` and visit [http://localhost:4000/products](http://localhost:4000/products). Let's follow the "New Product" link and click the "Save" button without providing any input. We should be greeted with the following output:

```
```text
Oops, something went wrong! Please check the errors below.
```

When we submit the form, we can see all the validation errors inline with the inputs. Nice! Out of the box, the context generator included the schema fields in our form template and we can see our default validations for required inputs are in effect. Let's enter some example product data and resubmit the form:

```
```text
Product created successfully.
Title: Metaprogramming Elixir
Expand Down Expand Up @@ -312,7 +312,7 @@ We modified our `show` action to pipe our fetched product into `Catalog.inc_page

We can also see our atomic update in action in the ecto debug logs:

```
```text
[debug] QUERY OK source="products" db=0.5ms idle=834.5ms
UPDATE "products" AS p0 SET "views" = p0."views" + $1 WHERE (p0."id" = $2) RETURNING p0."views" [1, 1]
```
Expand Down Expand Up @@ -427,7 +427,6 @@ INSERT INTO "categories" ("title","inserted_at","updated_at") VALUES ($1,$2,$3)

Perfect. Before we integrate categories in the web layer, we need to let our context know how to associate products and categories. First, open up `lib/hello/catalog/product.ex` and add the following association:


```diff
+ alias Hello.Catalog.Category

Expand All @@ -448,7 +447,6 @@ We used `Ecto.Schema`'s `many_to_many` macro to let Ecto know how to associate o

With our schema associations set up, we can implement the selection of categories in our product form. To do so, we need to translate the user input of catalog IDs from the front-end to our many-to-many association. Fortunately Ecto makes this a breeze now that our schema is set up. Open up your catalog context and make the following changes:


```diff
+ alias Hello.Catalog.Category

Expand Down Expand Up @@ -543,7 +541,7 @@ We added a `category_select` above our save button. Now let's try it out. Next,

Now if we start the server with `mix phx.server` and visit [http://localhost:4000/products/new](http://localhost:4000/products/new), we'll see the new category multiple select input. Enter some valid product details, select a category or two, and click save.

```
```text
Title: Elixir Flashcards
Description: Flash card set for the Elixir programming language
Price: 5.000000
Expand Down Expand Up @@ -882,7 +880,7 @@ The `link` function component from `Phoenix.LiveView.Helpers` accepts a `:method

Let's try it out. Start your server with `mix phx.server` and visit a product page. If we try clicking the add to cart link, we'll be greeted by an error page with the following logs in the console:

```
```text
[info] POST /cart_items
[debug] Processing with HelloWeb.CartItemController.create/2
Parameters: %{"_method" => "post", "product_id" => "1", ...}
Expand Down Expand Up @@ -987,7 +985,7 @@ Now that we can calculate price totals, let's try it out! Visit [`http://localho

Our cart page is almost complete, but submitting the form will yield yet another error.

```
```text
Request: POST /cart
** (exit) an exception was raised:
** (UndefinedFunctionError) function HelloWeb.CartController.update/2 is undefined or private
Expand Down Expand Up @@ -1197,7 +1195,6 @@ $ mix ecto.migrate

Before we render information about our orders, we need to ensure our order data is fully populated and can be looked up by a current user. Open up your orders context in `lib/hello/orders.ex` and replace your `get_order!/1` function by a new `get_order!/2` definition:


```elixir
def get_order!(user_uuid, id) do
Order
Expand Down
2 changes: 0 additions & 2 deletions guides/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ Reloading [http://localhost:4000](http://localhost:4000) should show us a comple

To be specific about the content type, we can use [`put_resp_content_type/2`] in conjunction with [`send_resp/3`].


```elixir
def index(conn, _params) do
conn
Expand Down Expand Up @@ -499,7 +498,6 @@ end

Whenever the `with` conditions do not match, `HelloWeb.MyFallbackController` will receive the original `conn` as well as the result of the action and respond accordingly.


[`/hello/Frank`]: http://localhost:4000/hello/Frank
[`assign/3`]: `Plug.Conn.assign/3`
[`clear_flash/1`]: `Phoenix.Controller.clear_flash/1`
Expand Down
9 changes: 4 additions & 5 deletions guides/deployment/fly.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The only thing we'll need for this guide is a working Phoenix application. For t

You can just:

```
```console
$ mix phx.new my_app
```

Expand Down Expand Up @@ -208,26 +208,25 @@ Our next step is to add the `topologies` configuration to `config/runtime.exs`.

This configures `libcluster` to use the `DNSPoll` strategy and look for other deployed apps using the `$FLY_APP_NAME` on the `.internal` private network.


#### Controlling the name for our node

We need to control the naming of our Elixir nodes. To help them connect up, we'll name them using this pattern: `[email protected]`. To do this, we'll generate the release config.

```
```console
$ mix release.init
```

Then edit the generated `rel/env.sh.eex` file and add the following lines:

```
```console
ip=$(grep fly-local-6pn /etc/hosts | cut -f 1)
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE=$FLY_APP_NAME@$ip
```

After making the change, deploy your app!

```
```console
$ fly deploy
```

Expand Down
12 changes: 7 additions & 5 deletions guides/deployment/heroku.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ https://mysterious-meadow-6277.herokuapp.com/ | https://git.heroku.com/mysteriou
The buildpack uses a predefined Elixir and Erlang version, but to avoid surprises when deploying, it is best to explicitly list the Elixir and Erlang version we want in production to be the same we are using during development or in your continuous integration servers. This is done by creating a config file named `elixir_buildpack.config` in the root directory of your project with your target version of Elixir and Erlang:

```
```console
# Elixir version
elixir_version=1.14.0

Expand All @@ -110,7 +110,7 @@ hook_post_compile="eval mix assets.deploy && rm -f _build/esbuild*"

Finally, let's tell the build pack how to start our webserver. Create a file named `Procfile` at the root of your project:

```
```console
web: mix phx.server
```

Expand Down Expand Up @@ -139,7 +139,7 @@ When using this buildpack, you want to delegate all asset bundling to `npm`. So

The Phoenix Static buildpack uses a predefined Node.js version, but to avoid surprises when deploying, it is best to explicitly list the Node.js version we want in production to be the same we are using during development or in your continuous integration servers. This is done by creating a config file named `phoenix_static_buildpack.config` in the root directory of your project with your target version of Node.js:

```
```text
# Node.js version
node_version=10.20.1
```
Expand Down Expand Up @@ -374,9 +374,11 @@ $ heroku run "POOL_SIZE=2 mix ecto.migrate"
Heroku gives you the ability to connect to your dyno with an IEx shell which allows running Elixir code such as database queries.

- Modify the `web` process in your Procfile to run a named node:
```

```text
web: elixir --sname server -S mix phx.server
```

- Redeploy to Heroku
- Connect to the dyno with `heroku ps:exec` (if you have several applications on the same repository you will need to specify the app name or the remote name with `--app APP_NAME` or `--remote REMOTE_NAME`)
- Launch an iex session with `iex --sname console --remsh server`
Expand Down Expand Up @@ -409,7 +411,7 @@ To https://git.heroku.com/mysterious-meadow-6277.git

This has to do with stale dependencies which are not getting recompiled properly. It's possible to force Heroku to recompile all dependencies on each deploy, which should fix this problem. The way to do it is to add a new file called `elixir_buildpack.config` at the root of the application. The file should contain this line:

```
```text
always_rebuild=true
```

Expand Down
1 change: 0 additions & 1 deletion guides/directory_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ You can learn more about applications in [Elixir's official docs for Application

The `lib/hello/mailer.ex` file holds the `Hello.Mailer` module, which defines the main interface to deliver e-mails:


```elixir
defmodule Hello.Mailer do
use Swoosh.Mailer, otp_app: :hello
Expand Down
2 changes: 1 addition & 1 deletion guides/ecto.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ iex> changeset = User.changeset(%User{}, params)
errors: [],
data: #Hello.User<>,
valid?: true
>
>
```

Our new changeset is valid.
Expand Down
1 change: 1 addition & 0 deletions guides/howto/custom_error_pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ However, implementing the `Plug.Exception` protocol by hand can be convenient in
Exception actions are functions that can be triggered by the error page, and they're basically a list of maps defining a `label` and a `handler` to be executed.

They are rendered in the error page as a collection of buttons and follow the format of:

```elixir
[
%{
Expand Down
5 changes: 3 additions & 2 deletions guides/introduction/community.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ There are a number of places to connect with community members at all experience
* We're on Libera IRC in the [\#elixir](https://web.libera.chat/?channels=#elixir) channel.

* [Request an invitation](https://elixir-slackin.herokuapp.com/) and join the #phoenix channel on [Slack](https://elixir-lang.slack.com).

* Feel free to join and check out the #phoenix channel on [Discord](https://discord.gg/elixir).

* Read about [bug reports](https://github.com/phoenixframework/phoenix/blob/master/CONTRIBUTING.md#bug-reports) or open an issue in the Phoenix [issue tracker](https://github.com/phoenixframework/phoenix/issues).
Expand All @@ -21,6 +21,7 @@ There are a number of places to connect with community members at all experience
* The source for these guides is [on GitHub](https://github.com/phoenixframework/phoenix/tree/master/guides). To help improve the guides, please report an [issue](https://github.com/phoenixframework/phoenix/issues) or open a [pull request](https://github.com/phoenixframework/phoenix/pulls).

## Books

* [Programming Phoenix LiveView - Interactive Elixir Web Programming Without Writing Any JavaScript - 2021 (by Bruce Tate and Sophie DeBenedetto)](https://pragprog.com/titles/liveview/programming-phoenix-liveview/)

* [Real-Time Phoenix - Build Highly Scalable Systems with Channels (by Stephen Bussey - 2020)](https://pragprog.com/book/sbsockets/real-time-phoenix)
Expand All @@ -38,7 +39,7 @@ There are a number of places to connect with community members at all experience
* [Phoenix LiveView Free Course (by The Pragmatic Studio - 2020)](https://pragmaticstudio.com/courses/phoenix-liveview)

* [Groxio LiveView: Self Study Program (by Bruce Tate - 2020)](https://grox.io/language/liveview/course)

* [Alchemist Camp: Learn Elixir and Phoenix by building (2018-2022)](https://alchemist.camp/episodes)

* [The Complete Elixir and Phoenix Bootcamp Master Functional Programming Techniques with Elixir and Phoenix while Learning to Build Compelling Web Applications (by Stephen Grider - 2017)](https://www.udemy.com/the-complete-elixir-and-phoenix-bootcamp-and-tutorial/)
Expand Down
3 changes: 3 additions & 0 deletions guides/mix_tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ If we don't specify a router for this task, it will default to the router Phoeni
$ mix phx.routes
GET / TaskTester.PageController.index/2
```

We can also specify an individual router if we have more than one for our application.

```console
Expand All @@ -377,12 +378,14 @@ This is the task we use to get our application running. It takes no arguments at
$ mix phx.server
[info] Running TaskTesterWeb.Endpoint with Cowboy on port 4000 (http)
```

It will silently ignore our `DoesNotExist` argument:

```console
$ mix phx.server DoesNotExist
[info] Running TaskTesterWeb.Endpoint with Cowboy on port 4000 (http)
```

If we would like to start our application and also have an `IEx` session open to it, we can run the Mix task within `iex` like this, `iex -S mix phx.server`.

```console
Expand Down
Loading

0 comments on commit 64ab574

Please sign in to comment.