Skip to content

Commit

Permalink
Use downdoc to convert README.adoc to README.md
Browse files Browse the repository at this point in the history
- use testing tag if the version is a prerelease
  • Loading branch information
ggrossetie committed Jan 12, 2023
1 parent 4833e4e commit 1b1e64f
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 85 deletions.
32 changes: 26 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
"bestikk-log": "0.1.0",
"chai": "4.3.7",
"dirty-chai": "2.0.1",
"downdoc": "^1.0.0-beta.9",
"eslint": "^8.10.0",
"eslint-config-standard": "^17.0.0-1",
"libnpmpublish": "4.0.2",
"mocha": "10.2.0",
"pacote": "^12.0.2",
"semver": "^7.3.8",
"sinon": "15.0.1"
}
}
62 changes: 62 additions & 0 deletions packages/asciidoctor/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
= Asciidoctor.js: AsciiDoc in JavaScript powered by Asciidoctor

Asciidoctor.js brings AsciiDoc to the JavaScript world!

This project uses https://opalrb.com/[Opal] to transpile http://asciidoctor.org[Asciidoctor], a modern implementation of AsciiDoc, from Ruby to JavaScript to produce _asciidoctor.js_.
The _asciidoctor.js_ script can be run on any JavaScript platform, including Node.js, GraalVM and, of course, a web browser.

== Install

$ npm i asciidoctor --save

== Usage

Here is a simple example that converts AsciiDoc to HTML5:

.sample.js
[source,javascript]
----
import asciidoctor from 'asciidoctor'
const Asciidoctor = asciidoctor() // <1>
const content = 'http://asciidoctor.org[*Asciidoctor*] ' +
'running on https://opalrb.com[_Opal_] ' +
'brings AsciiDoc to Node.js!'
const html = Asciidoctor.convert(content) // <2>
console.log(html) // <3>
----
<1> Instantiate the Asciidoctor.js library
<2> Convert AsciiDoc content to HTML5 using Asciidoctor.js
<3> Print the HTML5 output to the console

Save the file as _sample.js_ and run it using the `node` command:

$ node sample.js

You should see the following output in your terminal:

[source,html]
----
<div class="paragraph">
<p><a href="http://asciidoctor.org"><strong>Asciidoctor</strong></a> running on <a href="http://opalrb.com"><em>Opal</em></a> brings AsciiDoc to Node.js!</p>
</div>
----

If you want to know more about Asciidoctor.js, please read the https://docs.asciidoctor.org/asciidoctor.js/latest/[User Manual].

== Contributing

In the spirit of https://www.gnu.org/philosophy/free-sw.html[free software], _everyone_ is encouraged to help improve this project.
If you discover errors or omissions in the source code, documentation, or website content, please don't hesitate to submit an issue or open a pull request with a fix.
New contributors are always welcome!

The https://github.com/asciidoctor/asciidoctor.js/blob/main/CONTRIBUTING.adoc[Contributing] guide provides information on how to contribute.

If you want to write code, the https://github.com/asciidoctor/asciidoctor.js/blob/main/CONTRIBUTING-CODE.adoc[Contributing Code] guide will help you to get started quickly.

== Copyright

Copyright (C) 2013-present Dan Allen, Guillaume Grossetie, Anthonny Quérouil and the Asciidoctor Project.
Free use of this software is granted under the terms of the MIT License.

See the https://github.com/asciidoctor/asciidoctor.js/blob/main/LICENSE[LICENSE] file for details.
59 changes: 0 additions & 59 deletions packages/asciidoctor/README.md

This file was deleted.

17 changes: 2 additions & 15 deletions packages/core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"README.md"
],
"scripts": {
"postpublish": "downdoc --postpublish",
"prepublishOnly": "downdoc --prepublish",
"test:graalvm": "node tasks/graalvm.cjs",
"test:node": "mocha spec/*/*.spec.cjs && npm run test:node:esm",
"test:node:esm": "mocha --experimental-json-modules spec/node/asciidoctor.spec.js",
Expand Down Expand Up @@ -91,7 +89,6 @@
"dirty-chai": "2.0.1",
"documentation": "^14.0.0",
"dot": "1.1.3",
"downdoc": "^1.0.0-beta.8",
"ejs": "3.1.8",
"eslint": "8.31.0",
"handlebars": "4.7.7",
Expand Down
18 changes: 16 additions & 2 deletions tasks/publish.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
'use strict'
const path = require('path')
const fs = require('fs')
const fsp = require('node:fs/promises')
const log = require('bestikk-log')
const semver = require('semver')
const pacote = require('pacote') // see: http://npm.im/pacote
const { publish: npmPublish } = require('libnpmpublish')
const downdoc = require('downdoc')

const publish = async (directory) => {
const pkg = require(path.join(directory, 'package.json'))
if (process.env.DRY_RUN) {
const pkg = require(path.join(directory, 'package.json'))
console.log(`${pkg.name}@${pkg.version}`)
} else {
const inputReadme = path.join(directory, 'README.adoc')
const hiddenReadme = path.join(directory, '.README.adoc')
const outputReadme = path.join(directory, 'README.md')
await fsp
.readFile(inputReadme, 'utf8')
.then((asciidoc) => fsp.writeFile(outputReadme, downdoc(asciidoc) + '\n', 'utf8'))
await fsp.rename(inputReadme, hiddenReadme)
const manifest = await pacote.manifest(directory)
const tarData = await pacote.tarball(directory)
return npmPublish(manifest, tarData, {
const tag = semver.prerelease(pkg.version) ? 'testing' : 'latest'
await npmPublish(manifest, tarData, {
access: 'public',
defaultTag: tag,
forceAuth: {
token: process.env.NPM_AUTH_TOKEN
}
})
await fsp.rename(hiddenReadme, inputReadme)
await fsp.unlink(outputReadme)
}
}

Expand Down

0 comments on commit 1b1e64f

Please sign in to comment.