-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cambios y mejoras desde apuntes de D3D
Ni la generación de tareas es correcta ni el docstats
- Loading branch information
1 parent
21498ae
commit 7cc8c75
Showing
20 changed files
with
500 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
name: Generar, testear y publicar | ||
name: Publicar | ||
|
||
on: | ||
push: | ||
branches-ignore: [master] | ||
pull_request: | ||
branches-ignore: [master] | ||
workflow_dispatch: | ||
branches-ignore: [master] | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build-and-publish: | ||
|
@@ -18,35 +16,39 @@ jobs: | |
with: | ||
persist-credentials: false | ||
|
||
- name: Extract el nombre de la rama | ||
uses: nelonoel/branch-name@v1 | ||
env: | ||
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | ||
|
||
- name: Configurar Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.7 | ||
|
||
- name: Instalar dependencias | ||
run: bundle install | ||
run: | | ||
sudo apt-get update -y -qq | ||
sudo apt-get install pkg-config libxml2-dev libxslt-dev default-jre graphviz bison flex libffi-dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev fonts-lyx cmake | ||
bundle config build.nokogiri --use-system-libraries | ||
bundle install | ||
- name: Generar la documentación | ||
run: bundle exec rake build | ||
|
||
- name: Testear | ||
run: bundle exec rake tests | ||
|
||
- name: Publicar | ||
if: | | ||
github.event != 'pull_request' || ( | ||
github.event.pull_request.types == 'closed' && | ||
github.event.pull_request.merged_by != '' | ||
) | ||
run: bundle exec rake tests:all | ||
|
||
- name: Generar la documentación | ||
run: bundle exec rake build:html build:pdf | ||
|
||
- name: Publicar web | ||
uses: JamesIves/[email protected] | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
BRANCH: gh-pages | ||
FOLDER: output/html | ||
TARGET_FOLDER: ${{ env.BRANCH_NAME }} | ||
TARGET_FOLDER: ${{ github.ref }} | ||
CLEAN: true | ||
|
||
- name: Publicar como 'release' | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: output/pdf/{*/*.pdf,*.zip} | ||
tag: ${{ github.ref }} | ||
file_glob: true | ||
overwrite: true | ||
prerelease: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.idea/ | ||
*.iml | ||
.vscode | ||
output/ | ||
.vscode/ | ||
*~ | ||
output/ | ||
stem-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,143 +1,7 @@ | ||
require 'json' | ||
require "nokogiri" | ||
Rake.add_rakelib 'lib/tasks' | ||
|
||
READING_SPEED_IN_WORDS_PER_MINUTE = 200 | ||
|
||
PROJECT_DIR = Rake.application.original_dir | ||
|
||
CONTENT_DIR = File.join(PROJECT_DIR, "content") | ||
CONFIG_DIR = File.join(PROJECT_DIR, "config") | ||
OUTPUT_DIR = File.join(PROJECT_DIR, "output") | ||
|
||
DOCUMENT_MAIN_FILE = File.join(CONTENT_DIR, "main.adoc") | ||
DOCSTATS_FILE = File.join(CONTENT_DIR, "docstats.adoc") | ||
|
||
INCLUDED_FILES = FileList[File.join(CONTENT_DIR, "**/*.adoc"), | ||
File.join(CONFIG_DIR, "**/*.adoc"), | ||
File.join(CONFIG_DIR, "**/*.yml") | ||
].exclude(DOCUMENT_MAIN_FILE) | ||
|
||
MEDIA_FILES = FileList[File.join(CONTENT_DIR, "**/media/**", "*.jpg"), | ||
File.join(CONTENT_DIR, "**/media/**", "*.png"), | ||
File.join(CONTENT_DIR, "**/media/**", "*.svg")] | ||
|
||
OUTPUT_HTML_FILE = File.join(OUTPUT_DIR, "html", "index.html") | ||
OUTPUT_HTML_DIR = File.dirname(OUTPUT_HTML_FILE) | ||
|
||
OUTPUT_PDF_FILE = File.join(OUTPUT_DIR, "pdf", "sistemas-operativos.pdf") | ||
OUTPUT_PDF_DIR = File.dirname(OUTPUT_PDF_FILE) | ||
|
||
OUTPUT_EPUB_FILE = File.join(OUTPUT_DIR, "epub", "sistemas-operativos.epub") | ||
OUTPUT_EPUB_DIR = File.dirname(OUTPUT_EPUB_FILE) | ||
|
||
task :default => :build | ||
task :build => [:docstats, :html] | ||
|
||
desc 'Generar la versión en HTML de la documentación' | ||
task :html => [OUTPUT_HTML_FILE, :html_media_files] | ||
|
||
file OUTPUT_HTML_FILE => [OUTPUT_HTML_DIR, DOCUMENT_MAIN_FILE, *INCLUDED_FILES] do |t| | ||
sh "asciidoctor", "--backend", "html5", DOCUMENT_MAIN_FILE, "-o", t.name | ||
end | ||
|
||
file :html_media_files => OUTPUT_HTML_DIR do |t| | ||
MEDIA_FILES.each do |source| | ||
relative_part = source.dup | ||
relative_part.slice! CONTENT_DIR | ||
destination = File.join(OUTPUT_HTML_DIR, relative_part) | ||
destination_dir = File.dirname(destination) | ||
|
||
if File.exist? destination | ||
next if [File.ctime(source), File.mtime(source)].max <= \ | ||
[File.ctime(destination), File.mtime(destination)].max | ||
end | ||
mkdir_p destination_dir | ||
cp_r source, destination | ||
end | ||
end | ||
|
||
directory OUTPUT_HTML_DIR | ||
|
||
desc 'Generar la versión en PDF de la documentación' | ||
task :pdf => OUTPUT_PDF_FILE | ||
|
||
file OUTPUT_PDF_FILE => [OUTPUT_PDF_DIR, DOCUMENT_MAIN_FILE, *INCLUDED_FILES] do |t| | ||
sh "asciidoctor", "--require", "asciidoctor-pdf", "--backend", "pdf", DOCUMENT_MAIN_FILE, "-o", t.name | ||
end | ||
|
||
directory OUTPUT_PDF_DIR | ||
|
||
desc 'Generar la versión en EPUB de la documentación' | ||
task :epub => OUTPUT_EPUB_FILE | ||
|
||
file OUTPUT_EPUB_FILE => [OUTPUT_EPUB_DIR, DOCUMENT_MAIN_FILE, *INCLUDED_FILES] do |t| | ||
sh "asciidoctor", "--require", "asciidoctor-epub3", "--backend", "epub3", DOCUMENT_MAIN_FILE, "-o", t.name | ||
end | ||
|
||
directory OUTPUT_EPUB_DIR | ||
|
||
desc 'Ejecutar los tests' | ||
task :tests => [:test_missing_variables, :test_htmlproofer] | ||
|
||
desc 'Test de HTMLProofer' | ||
task :test_htmlproofer => :html do |t| | ||
typhoeus_config = { | ||
:headers => { | ||
"User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0", | ||
}, | ||
:ssl_verifyhost => 0, | ||
:ssl_verifypeer => false, | ||
} | ||
sh "htmlproofer", "--typhoeus_config", typhoeus_config.to_json, OUTPUT_HTML_DIR | ||
end | ||
|
||
desc 'Test de variables no definidas' | ||
task :test_missing_variables => OUTPUT_HTML_FILE do |t| | ||
document = Nokogiri::HTML.parse(open(OUTPUT_HTML_FILE)) | ||
variables = document.xpath('//body//text()[not(ancestor::div[@class="stemblock"])]').flat_map do |text| | ||
matches = text.content.gsub(/\\\$.*?\\\$/, "").scan(/\{\w+\}/) | ||
end.uniq.sort | ||
|
||
fail "Se han encontrado #{variables.size} variables no definidas:\n#{variables.join("\n")}" unless variables.empty? | ||
puts variables | ||
end | ||
|
||
desc 'Limpiar todos los archivos generados' | ||
task :clean do |t| | ||
rm_r OUTPUT_DIR | ||
end | ||
|
||
desc 'Generar el archivo de información estadística' | ||
task :docstats do |t| | ||
# Contamos las palabras en la versión HTML del documento | ||
output_html = `asciidoctor --backend html5 #{DOCUMENT_MAIN_FILE} -o -` | ||
docstats = open(DOCSTATS_FILE, "w") | ||
|
||
document = Nokogiri::HTML.parse(output_html) | ||
document.css(".sect1 > h2 + .sectionbody").each do |sectionbody| | ||
if matches = /^(?<chapter_number>\d+)\. /.match(sectionbody.previous_element) | ||
chapter_number = matches['chapter_number'] | ||
|
||
wordcount = sectionbody.text().scan(/[\p{Alnum}\-']+/).length() | ||
reading_time = (wordcount.to_f / READING_SPEED_IN_WORDS_PER_MINUTE).round | ||
|
||
# Construir la cadena de texto con el tiempo de lectura | ||
if reading_time == 1 | ||
reading_time_string = "1 minuto" | ||
elsif reading_time < 60 | ||
reading_time_string = "#{reading_time} minutos" | ||
elsif reading_time == 60 | ||
reading_time_string = "1 hora" | ||
else | ||
reading_time_string = "#{reading_time / 60} horas y #{reading_time % 60} minutos" | ||
end | ||
|
||
docstats.puts ":C%02i_words: %i" % [chapter_number, wordcount] | ||
docstats.puts ":C%02i_reading_time: %s" % [chapter_number, reading_time_string] | ||
|
||
puts "C%02i: %8i %8i (%s)" % [chapter_number, wordcount, reading_time, reading_time_string] | ||
end | ||
end | ||
ensure | ||
docstats.close | ||
end | ||
task :config do |t| | ||
CONFIG[:asciidoctor_pdf_opts] = [ | ||
'--require', 'asciidoctor-mathematical', '-a', 'mathematical-format=svg', | ||
] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Archivo de configuración específica del backend HTML5. | ||
// | ||
// Localización de los archivos docinfo | ||
:docinfodir: ../config/html5 | ||
// Localización de los archivos docinfo. | ||
:docinfodir: {basedir}/config/html5 | ||
:docinfo: shared-head |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Archivo de configuración específica del backed PDF. | ||
// | ||
// Archivo de tema para asciidoctor-pdf | ||
:pdf-theme: config/pdf/pdf-theme.yml | ||
// Activar la portada | ||
:title-page: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
extends: default | ||
title-page: | ||
authors: | ||
content: | ||
name_only: "{author}" | ||
with_email: "{author} <{email}>" | ||
with_url: "{url}[{author}]" | ||
image: | ||
align: center | ||
caption: | ||
align: inherit | ||
admonition: | ||
icon: | ||
time: | ||
name: fa-clock | ||
stroke_color: 871452 | ||
size: 24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
:academic-year: 20XX-20XY | ||
:ejemplos_branch: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Struct.new('Config', | ||
:asciidoctor_opts, | ||
:asciidoctor_html_opts, | ||
:asciidoctor_epub_opts, | ||
:asciidoctor_pdf_opts, | ||
:htmlproofer_opts, | ||
keyword_init: true) do | ||
def initialize() | ||
default_values = { | ||
asciidoctor_opts: [], | ||
asciidoctor_html_opts: [], | ||
asciidoctor_epub_opts: [], | ||
asciidoctor_pdf_opts: [], | ||
htmlproofer_opts: ENV.key?('HTMLPROOFER_DISABLE_EXTERNAL') ? ["--disable-external"] : [] | ||
} | ||
super(default_values) | ||
end | ||
end | ||
|
||
CONFIG = Struct::Config.new() |
Oops, something went wrong.