From nobody Sun Dec 12 13:48:07 2021 X-Original-To: dev-commits-doc-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6B97A18E2B2A for ; Sun, 12 Dec 2021 13:48:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JBmDm1BvKz4jgJ; Sun, 12 Dec 2021 13:48:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F20EF22222; Sun, 12 Dec 2021 13:48:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BCDm7ix004325; Sun, 12 Dec 2021 13:48:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BCDm7DQ004324; Sun, 12 Dec 2021 13:48:07 GMT (envelope-from git) Date: Sun, 12 Dec 2021 13:48:07 GMT Message-Id: <202112121348.1BCDm7DQ004324@gitrepo.freebsd.org> To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org From: Sergio Carlavilla Delgado Subject: git: f1202f5e14 - main - Remove Python dependency List-Id: Commit messages for all branches of the doc repository List-Archive: https://lists.freebsd.org/archives/dev-commits-doc-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-doc-all@freebsd.org X-BeenThere: dev-commits-doc-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: carlavilla X-Git-Repository: doc X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f1202f5e1430ee863fa77d03e8459010cf5c9bff Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639316888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=J/sYOt/zUTnrITTJ8Ww9e+VvtmPkW+8UAmADYQB0PwI=; b=meeQlhj12NL2EBk/4LdiwL9dYLlURqRJ8M692oF36Secb+XZ8ENgd03AZMGdC9OqDOtw21 /Vuf/36GonEx1FJdbEykeofb8Jo/XR8iLfsDjfThISu9hS6ErytME3QB1Xi1huOHs0o6lE 45C3At9mIJnZfuQ3UFqnmgiyF4XqpAZ4/8ZKbk8s/FURBvOgLe6gr00AwqmCqOAYxOPpIQ KgrUZk8w9m+fLE4CXnXyEYLZuaKhD+cfRvUNsjN/FnGZkooCA5S2ZUofkclZK9iPtlF8nQ qPWkZvjxrKjtsWl5h/D5H+kpeQtfcWqq/ZEj9/BYnb6ecx/fp7S7RPws3/Z0Dw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639316888; a=rsa-sha256; cv=none; b=w1DDcEPEdgJ7Dze8AXzn0zhkEn6AjXOrvF3b/SkMWkzPURmbFLywX7HGIZzoqKivLrMuQ8 mge1Q8Sc5bZWs42EmLO9yjIPG9qdE32mvMlzCL51oJKUdXEPA7fvvUyd7pcn8mmvuNu4Vl STYTqKIlCA4CvVAtOScE0HRQP6lIEL+P2QofAjbx5qVSocrvexgrhnL9oZJKrwdZZpLa1D d/sMg6CAWrEWdWv3lDzdWORkgHlq5/jc3HLcRl16KqXtkK79/87DG1D+GK/KU4XeJMY17M TqmTJIocHGKd07ZHYEpepb4KQ61XTmy52lMfzSgF9Qk2LGLU8xxG/iuh0vL1KQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by carlavilla: URL: https://cgit.FreeBSD.org/doc/commit/?id=f1202f5e1430ee863fa77d03e8459010cf5c9bff commit f1202f5e1430ee863fa77d03e8459010cf5c9bff Author: Sergio Carlavilla Delgado AuthorDate: 2021-12-12 13:35:56 +0000 Commit: Sergio Carlavilla Delgado CommitDate: 2021-12-12 13:47:44 +0000 Remove Python dependency - Convert releases-toml to Ruby - Remove hardware notes creator script --- website/Makefile | 8 ++-- website/tools/hardware-notes-creator.py | 64 ----------------------------- website/tools/releases-toml.py | 72 --------------------------------- website/tools/releases-toml.rb | 55 +++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 139 deletions(-) diff --git a/website/Makefile b/website/Makefile index e62d177b57..c1f3d6893e 100644 --- a/website/Makefile +++ b/website/Makefile @@ -18,8 +18,10 @@ MAINTAINER=carlavilla@FreeBSD.org # List of all languages we have content for ALL_LANGUAGES= de el en es fr hu it ja nl ru tr zh-cn zh-tw -PYTHON_CMD = /usr/local/bin/python3 -HUGO_CMD = /usr/local/bin/hugo +LOCALBASE?= /usr/local + +RUBY_CMD = ${LOCALBASE}/bin/ruby +HUGO_CMD = ${LOCALBASE}/bin/hugo HUGO_ARGS?= --verbose RUBYLIB = ../shared/lib .export RUBYLIB @@ -80,7 +82,7 @@ end-message: .PHONY generate-releases: data/releases.toml data/releases.toml: - ${PYTHON_CMD} ./tools/releases-toml.py -p ./shared/releases.adoc + ${RUBY_CMD} ./tools/releases-toml.rb run-local: .PHONY HUGO_DISABLELANGUAGES="${SKIP_LANGS}" ${HUGO_CMD} server \ diff --git a/website/tools/hardware-notes-creator.py b/website/tools/hardware-notes-creator.py deleted file mode 100644 index 67c27ccb7d..0000000000 --- a/website/tools/hardware-notes-creator.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -""" -BSD 2-Clause License - -Copyright (c) 2020-2021, The FreeBSD Project -Copyright (c) 2020-2021, Sergio Carlavilla - -This script will generate the Table of Contents of the Handbook -""" -#!/usr/bin/env python3 - -import sys, getopt -import ntpath -import subprocess -import os - -manPagesPath = "" - -def loadManPages(manPagesDir): - manPagesPaths = [] - - for root, _, files in os.walk(manPagesDir): - for file in files: - if file.endswith(".4"): - manPagesPaths.append(os.path.join(root, file)) - return manPagesPaths - -def createHardwareNotesDirectory(path): - try: - os.mkdir(path) - except OSError: - print ("Creation of the directory %s failed" % path) - else: - print ("Successfully created the directory %s " % path) - -def main(argv): - - try: - opts, args = getopt.getopt(argv,"hp:",["path="]) - except getopt.GetoptError: - print('hardware-notes-creator.py -p ') - sys.exit(2) - - for opt, arg in opts: - if opt == '-h': - print('hardware-notes-creator.py -p ') - sys.exit() - elif opt in ("-p", "--path"): - manPagesPath = arg - - manPages = loadManPages("/home/carlavilla/Projects/base/src/share/man/man4/") - createHardwareNotesDirectory('/home/carlavilla/Projects/testsssss') - - for manPage in manPages: - manPageParsed = subprocess.getoutput("mandoc -Tmarkdown " + manPage + " | sed -n '/# HARDWARE/,/#/{/#/!p;}'") - - if len(manPageParsed) > 0: - manPageName = ntpath.basename(manPage).replace(".4", "") - - with open('/home/carlavilla/Projects/testsssss/{}.adoc'.format(manPageName), 'w', encoding = 'utf-8') as manPageFile: - manPageFile.write(manPageParsed) - -if __name__ == "__main__": - main(sys.argv[1:]) diff --git a/website/tools/releases-toml.py b/website/tools/releases-toml.py deleted file mode 100644 index 2dc96d310f..0000000000 --- a/website/tools/releases-toml.py +++ /dev/null @@ -1,72 +0,0 @@ -# -*- coding: utf-8 -*- -""" -BSD 2-Clause License - -Copyright (c) 2020-2021, The FreeBSD Project -Copyright (c) 2020-2021, Sergio Carlavilla - -This script will convert the releases.adoc file to releases.toml -in this way we can share the releases variables between AsciiDoctor and Hugo -""" -#!/usr/bin/env python3 - -import sys, getopt -import re - -variables = {} - -def getValueByKey(key): - return variables[key.replace("{", "").replace("}", "")].replace("\"", "") - -def loadVariables(path): - with open(path, 'r', encoding = 'utf-8') as releasesFile: - line = releasesFile.readline() - - while line: - if (re.match(r"^:{1}[^\n]+", line)): - variable = re.sub(':', '', line.strip(), 1) - variable = re.sub(': ', '="', variable) - variable += "\"" - data = variable.split("=") - - if (len(data) == 2): - variables.update( {data[0] : data[1]} ) - - line = releasesFile.readline() - -def main(argv): - path = '' - - try: - opts, args = getopt.getopt(argv,"hp:",["path="]) - except getopt.GetoptError: - print('releases-toml.py -p ') - sys.exit(2) - for opt, arg in opts: - if opt == '-h': - print('releases-toml.py -p ') - sys.exit() - elif opt in ("-p", "--path"): - path = arg - - releasesTOML = "# Code @" + "generated by the FreeBSD Documentation toolchain. DO NOT EDIT.\n" - releasesTOML += "# Please don't change this file manually but run `make` to update it.\n" - releasesTOML += "# For more information, please read the FreeBSD Documentation Project Primer\n" - releasesTOML += '\n' - - loadVariables(path) - - for key in variables: - foundBraces = re.search(r"\{.*?\}", variables[key]) - - if (foundBraces): - braces = foundBraces.group(0) - releasesTOML += key + "=" + variables[key].replace(braces, getValueByKey(braces)) + "\n" - else: - releasesTOML += key + "=" + variables[key] + "\n" - - with open('./data/releases.toml', 'w', encoding = 'utf-8') as releasesTOMLFile: - releasesTOMLFile.write(releasesTOML) - -if __name__ == "__main__": - main(sys.argv[1:]) diff --git a/website/tools/releases-toml.rb b/website/tools/releases-toml.rb new file mode 100644 index 0000000000..3dbd2f6ea2 --- /dev/null +++ b/website/tools/releases-toml.rb @@ -0,0 +1,55 @@ +#!/usr/bin/env ruby + +=begin + +BSD 2-Clause License +Copyright (c) 2020-2021, The FreeBSD Project +Copyright (c) 2020-2021, Sergio Carlavilla + +This script will merge all the pgpkeys into one single file + +=end + +def getValueByKey(key, variables) + return variables.fetch(key.gsub("{", "").gsub("}", "")).gsub("\"", "") +end + +def mapVariables(path) + variables = Hash.new + + File.foreach(path).with_index do |line| + if line.match("^:{1}[^\n]+") + variable = line.strip.sub(":", '') + variable = variable.sub(": ", "=\"") + variable << "\"" + data = variable.split("=") + + if data.length == 2 + variables.store(data[0], data[1]) + end + end + end + + return variables +end + +# Main method +releasesTOMLFile = File.new("./data/releases.toml", "w") + +releasesTOMLFile.puts("# Code @" + "generated by the FreeBSD Documentation toolchain. DO NOT EDIT.\n") +releasesTOMLFile.puts("# Please don't change this file manually but run `make` to update it.\n") +releasesTOMLFile.puts("# For more information, please read the FreeBSD Documentation Project Primer\n") +releasesTOMLFile.puts("\n") + +variables = mapVariables("./shared/releases.adoc") + +variables.each do |key, value| + + if keyToFind = value.match("\{.*?\}") + releasesTOMLFile.puts(key + "=" + value.gsub(keyToFind[0], getValueByKey(keyToFind[0], variables)) + "\n") + else + releasesTOMLFile.puts(key + "=" + value + "\n") + end + +end +