Skip to content

Commit

Permalink
Merge pull request #99 from Raku/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
antoniogamiz authored Jun 27, 2020
2 parents 98875a7 + b40b2ca commit e0ce073
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 359 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
git clone https://github.com/antoniogamiz/mini-doc
zef install https://github.com/antoniogamiz/Perl6-LinkHealth.git
cd mini-doc
documentable setup
documentable setup -o
documentable start --topdir=test-doc -v -p -s --search-index -i
linkhealth --html-dir=html
docs-build:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/production-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Publish Production Docker Container
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: antoniogamiz/documentable
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: production.Dockerfile
tags: "latest"
18 changes: 18 additions & 0 deletions .github/workflows/testing-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Publish Testing Docker Container
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: antoniogamiz/documentable-testing
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: testing.Dockerfile
tags: "latest"
2 changes: 1 addition & 1 deletion META6.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Documentable",
"description": "An API for Raku documentation",
"version": "1.2.6",
"version": "1.2.7",
"perl": "6.d",
"authors": [
"@moritz",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Documentable, the Raku Doc API [![CI Status](https://circleci.com/gh/Raku/Documentable.svg?style=shield)](https://circleci.com/gh/Raku/Documentable) [![Build Status](https://travis-ci.org/Raku/Documentable.svg?branch=master)](https://travis-ci.org/Raku/Documentable) [![artistic](https://img.shields.io/badge/license-Artistic%202.0-blue.svg?style=flat)](https://opensource.org/licenses/Artistic-2.0)
# Documentable, the Raku Doc API [![CI Status](https://circleci.com/gh/Raku/Documentable.svg?style=shield)](https://circleci.com/gh/Raku/Documentable) [![Build Status](https://travis-ci.org/Raku/Documentable.svg?branch=master)](https://travis-ci.org/Raku/Documentable) [![Build Status](https://dev.azure.com/antoniogamiz10/Documentable/_apis/build/status/Raku.Documentable?branchName=master)](https://dev.azure.com/antoniogamiz10/Documentable/_build/latest?definitionId=1&branchName=master) [![artistic](https://img.shields.io/badge/license-Artistic%202.0-blue.svg?style=flat)](https://opensource.org/licenses/Artistic-2.0)

In this repository you can find all logic responsible for generating the
[official Raku documentation](https://docs.Raku.org/) or any other
Expand Down
24 changes: 24 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
trigger:
- master
- develop

pool:
vmImage: "windows-2019"

steps:
- script: |
echo Donwloading rakudo zip
curl https://rakudo.org/dl/rakudo/rakudo-moar-2020.06-01-win-x86_64.zip --output rakudo.zip
7z x rakudo.zip
displayName: "Download raku and zef"
- script: |
call npm -g install sass
curl https://graphviz.gitlab.io/_pages/Download/windows/graphviz-2.38.zip --output graphviz.zip
7z x graphviz.zip
displayName: "Install native dependencies"
- script: |
call %cd%\rakudo-2020.06\scripts\set-env.bat
set PATH=%cd%\release\bin\;%PATH%
zef install --/test --deps-only .
zef test .
displayName: "Run tests"
89 changes: 56 additions & 33 deletions lib/Documentable/CLI.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use Documentable::Utils::IO;
use Perl6::TypeGraph;
use Perl6::TypeGraph::Viz;
use JSON::Fast;
use File::Directory::Tree;

use Terminal::Spinners;
use Terminal::ANSIColor;
Expand All @@ -35,34 +36,68 @@ package Documentable::CLI {
say 'Execute "documentable --help" for more information.';
}

#| Downloads default assets to generate the site
#| Downloads and untar default assets to generate the site
multi MAIN (
"setup",
Bool :y(:$yes) = False #= Always accept the operation (to use in scripts)
Bool :o(:$override) = False
) {
DEBUG("Setting up the directory...");

my $tmpdir = tempdir;
shell "wget https://github.com/Raku/Documentable/releases/download/v1.0.1/assets.tar.gz -P {$tmpdir} -q";
shell "tar -xvzf {$tmpdir}/assets.tar.gz -C {$tmpdir} > /dev/null && rm {$tmpdir}/assets.tar.gz";

# warnings
my @assets-files = list-files($tmpdir);
my $overriden = False;
for @assets-files -> $file {
my $real-file = "." ~ $file.split("{$tmpdir}/assets")[*-1];
if $real-file.IO.e {
note colored("[WARNING] $real-file will be overriden by this operation", 'yellow');
$overriden = True;
}
constant $assetsDIR = "documentable-assets";
constant $assetsURL = "https://github.com/Raku/Documentable/releases/download/v1.0.1/{$assetsDIR}.tar.gz";

shell "curl -Ls {$assetsURL} --output {$assetsDIR}.tar.gz";
shell "tar -xzf {$assetsDIR}.tar.gz";
unlink("{$assetsDIR}.tar.gz");

my @assets-files = list-files($assetsDIR).map({.relative($assetsDIR).IO});
my @no-duplicated-files = @assets-files.grep({! .e});
my @duplicated-files = @assets-files.grep({.e});

for @duplicated-files -> $file {
note colored("[WARNING] $file will be overriden by this operation", 'yellow');
}
# proceed if ENTER is pressed
if ($yes or (not so prompt("Continue? Yes [ENTER] No [n]")) ) {
shell "cp -a {$tmpdir}/assets/* .";
say colored("Done.", "green");
exit 0;

say colored("Copying files...", "yellow");

# all directories must exist before copying
@assets-files.map({mkdir($_.dirname)});

for @no-duplicated-files -> $file {
copy($assetsDIR.IO.add($file), $file);
}
say colored("Skipped.", "red");

my Bool $override-files = $override or prompt("Continue? Yes [ENTER] No [n]");
if ( $override-files ) {
for @duplicated-files -> $file {
copy($assetsDIR.IO.add($file), $file);
}
}

rmtree($assetsDIR);
say colored("Done.", "green");
}

#| Delete files created by "documentable setup"
multi MAIN (
"clean"
) {
DEBUG("Cleaning up the directory...");

constant @files-to-delete = (
"Makefile",
"app.pl",
"app-start",
);
unlink(@files-to-delete);

constant @dirs-to-delete = (
"html",
"highlights",
"assets",
"template"
);
@dirs-to-delete.map({rmtree($_)});
}

#| Start the documentation generation with the specified options
Expand Down Expand Up @@ -363,18 +398,6 @@ package Documentable::CLI {
print-time("Updating files", $now, $verbose);
}

#| Delete files created by "documentable setup"
multi MAIN (
"clean"
) {
DEBUG("Cleaning up the directory...");
shell q:to/END/;
rm -rf html && rm -rf assets && rm -rf highlights \
&& rm app.pl && rm app-start && rm Makefile \
&& rm -rf template
END
}

#| Documentable version
multi MAIN (
Bool :V(:$version)!
Expand Down
4 changes: 2 additions & 2 deletions lib/Documentable/DocPage/Factory.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class Documentable::DocPage::Factory {
method generate-search-file() {
my $search-generator = Documentable::Search.new(prefix => $.config.url-prefix );
my @items = $search-generator.generate-entries($.registry);
my $template-path = "./template/search_template.js".IO ~~ :e ??
"./template/search_template.js" !!
my $template-path = "template/search_template.js".IO.e ??
"template/search_template.js" !!
zef-path("template/search_template.js");
my $template = slurp($template-path);
$template = $template.subst("ITEMS", @items.join(",\n"))
Expand Down
25 changes: 18 additions & 7 deletions t/101-cli.t
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
use Test;
use Test::Output;
use File::Directory::Tree;

use Documentable::CLI;
use Documentable::CLI {};

# We need to make sure the cache directory does not exist
# It might fail if there's a change of version

subtest 'no arguments provided' => {
output-like {Documentable::CLI::MAIN()}, /Execute/, "show help message";
}

subtest 'setup assets' => {
lives-ok {Documentable::CLI::MAIN('setup', :o)}, "Setup lives";
ok "assets".IO.e, "Assets directory created";
nok dir("assets") eq (), "Assets dir not empty";
nok "assets.tar.gz".IO.e, "tar.gz deleted";
}

subtest 'clean' => {
lives-ok {Documentable::CLI::MAIN('clean')}, "Clean lives";
}

subtest 'progress-bar-display' => {
# We need to make sure the cache directory does not exist
# It might fail if there's a change of version
rmtree("t/.cache-test-doc");
lives-ok {
Documentable::CLI::MAIN('start', :topdir('t/test-doc'),
:dirs('Language'), :p, :v)
Expand All @@ -24,15 +37,13 @@ subtest 'progress-bar-display' => {
output-like {Documentable::CLI::MAIN('start', :topdir('t/test-doc'), :dirs('Language'), :p, :verbose)},
/\[\=+\]?/,
"With --verbose";

rmtree("html");
}

subtest 'version command' => {
output-like {Documentable::CLI::MAIN(:version)}, /Documentable\sversion/, "long version";
output-like {Documentable::CLI::MAIN(:V)} , /Documentable\sversion/, "short version";
}





done-testing;
5 changes: 4 additions & 1 deletion t/102-update.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use Test;
use File::Directory::Tree;

use Documentable::CLI;
use Documentable::CLI {};

plan *;

Expand Down Expand Up @@ -59,6 +60,8 @@ subtest 'not regenerate all subindexes' => {

}

rmtree("html");

sub add-line($file) {
$file ~ "\n # comment to modify the file"
}
Expand Down
5 changes: 4 additions & 1 deletion t/103-highlight.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use Test;
use File::Directory::Tree;

use Documentable::CLI;
use Documentable::CLI {};

plan *;

Expand All @@ -9,4 +10,6 @@ subtest 'highlighter check' => {
"Dies when node is not available";
}

rmtree("html");

done-testing;
2 changes: 1 addition & 1 deletion t/402-factory.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ like %spawn<document>, /Raku/, "Home page generated correctly";
like %spawn<document>, /Raku/, "Error page generated correctly";

%spawn = $factory.generate-search-file() ;
like %spawn<document>, /'perl6-test'/, "Search script generated correctly";
like %spawn<document>, /raku/, "Search script generated correctly";

done-testing;
Loading

0 comments on commit e0ce073

Please sign in to comment.