Skip to content

Commit

Permalink
Merge pull request #352 from olafurpg/fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
olafurpg authored Jun 2, 2020
2 parents b00ab06 + 780348a commit fbaa078
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
25 changes: 16 additions & 9 deletions docs/docusaurus.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ several steps:
http://static.javadoc.io/

The static website gets generated in the `website/build` directory. You can copy
these files over to any static HTTP server to host your website. A simple `sbt docs/clean`
will delete the previous folder since the `DocusaurusPlugin` will also bind it to the
standard SBT `clean` task.
these files over to any static HTTP server to host your website. A simple
`sbt docs/clean` will delete the previous folder since the `DocusaurusPlugin`
will also bind it to the standard SBT `clean` task.

## Publish to GitHub pages locally

Expand Down Expand Up @@ -134,8 +134,8 @@ https://travis-ci.org/scalameta/mdoc/settings.

Add the following values:

- `GITHUB_DEPLOY_KEY`: the base64 encoded secret key. Note, the secret key is
the file without the `.pub` extension
- `GITHUB_DEPLOY_KEY` or `GIT_DEPLOY_KEY`: the base64 encoded secret key. Note,
the secret key is the file without the `.pub` extension
```sh
# macOS
cat myproject | base64 | pbcopy
Expand Down Expand Up @@ -184,7 +184,9 @@ docs 😎

## Include Scaladoc in site

You can configure a project to include Scaladocs in its site. Below is an example configuration that uses [sbt-unidoc](https://github.com/sbt/sbt-unidoc) to aggregate Scaladocs across multiple projects.
You can configure a project to include Scaladocs in its site. Below is an
example configuration that uses [sbt-unidoc](https://github.com/sbt/sbt-unidoc)
to aggregate Scaladocs across multiple projects.

```diff
// build.sbt
Expand All @@ -202,9 +204,13 @@ You can configure a project to include Scaladocs in its site. Below is an exampl
.dependsOn(myproject1, myproject2)
```

Make sure that you've added the [sbt-unidoc](https://github.com/sbt/sbt-unidoc#how-to-add-this-plugin) dependency to `project/plugins.sbt`.
Make sure that you've added the
[sbt-unidoc](https://github.com/sbt/sbt-unidoc#how-to-add-this-plugin)
dependency to `project/plugins.sbt`.

Now the `docs/docusaurusCreateSite` command will generate Scaladocs in the `website/static/api` directory, which you'll probably want to add to your `.gitignore`:
Now the `docs/docusaurusCreateSite` command will generate Scaladocs in the
`website/static/api` directory, which you'll probably want to add to your
`.gitignore`:

```diff
// .gitignore
Expand All @@ -217,7 +223,8 @@ Now the `docs/docusaurusCreateSite` command will generate Scaladocs in the `webs
+ website/static/api
```

You'll need to tweak your `siteConfig.js` file to make Docusaurus play nicely with Scaladoc's CSS. You may want to add a header link to your API docs too:
You'll need to tweak your `siteConfig.js` file to make Docusaurus play nicely
with Scaladoc's CSS. You may want to add a header link to your API docs too:

```diff
// website/siteConfig.js
Expand Down
9 changes: 5 additions & 4 deletions mdoc-sbt/src/main/scala/mdoc/DocusaurusPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object DocusaurusPlugin extends AutoPlugin {
"""|#!/usr/bin/env bash
|
|set -eu
|
|DEPLOY_KEY=${GIT_DEPLOY_KEY:-$GITHUB_DEPLOY_KEY}
|set-up-ssh() {
| echo "Setting up ssh..."
| mkdir -p $HOME/.ssh
Expand All @@ -63,15 +63,16 @@ object DocusaurusPlugin extends AutoPlugin {
| git config --global user.email "${MDOC_EMAIL:-mdoc@docusaurus}"
| git config --global push.default simple
| DEPLOY_KEY_FILE=$HOME/.ssh/id_rsa
| echo "$GITHUB_DEPLOY_KEY" | base64 --decode > ${DEPLOY_KEY_FILE}
| echo "$DEPLOY_KEY" | base64 --decode > ${DEPLOY_KEY_FILE}
| chmod 600 ${DEPLOY_KEY_FILE}
| eval "$(ssh-agent -s)"
| ssh-add ${DEPLOY_KEY_FILE}
|}
|DEPLOY_KEY=${GITHUB_DEPLOY_KEY:-}
|
|if [[ -n "$DEPLOY_KEY" ]]; then
|if [[ -n "${DEPLOY_KEY:-}" ]]; then
| set-up-ssh
|else
| echo "Can't setup SSH. To fix this problem, set the GIT_DEPLOY_KEY environment variable."
|fi
|
|yarn install
Expand Down

0 comments on commit fbaa078

Please sign in to comment.