diff --git a/generator/_config.yml b/generator/_config.yml index c21a5f8a8..d7ef1a791 100644 --- a/generator/_config.yml +++ b/generator/_config.yml @@ -1,7 +1,18 @@ #auto: true safe: false #include: ./pages/ -plugins: ./_plugins/ +plugins: + - ./_plugins/category_nav.rb + - ./_plugins/CfeLiquidUtils.rb + - ./_plugins/cfengineAddons.rb + - ./_plugins/CfeUtils.rb + - ./_plugins/debug.rb + - ./_plugins/gentagspages.rb + - ./_plugins/jekyll_asset_pipeline.rb + - ./_plugins/navigation.rb + - ./_plugins/redcarpet2_markdown.rb + - ./_plugins/references.rb + - ./_plugins/sitemap_generator.rb # baseurl: /docs/master/ git-repository: github.com/cfengine/documentation git-branch: "3.23" @@ -39,7 +50,7 @@ virtualbox: paginate: 500 pygments: true -markdown: redcarpet2 +markdown: kramdown redcarpet: extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "strikethrough", "superscript", "tables"] asset_pipeline: diff --git a/generator/_plugins/references.rb b/generator/_plugins/references.rb index 59ef40837..f32c04135 100644 --- a/generator/_plugins/references.rb +++ b/generator/_plugins/references.rb @@ -35,7 +35,7 @@ def read_yaml(base, name) # only alter markdown files md_class = ((defined? MarkdownConverter) ? MarkdownConverter : Jekyll::Converters::Markdown) - return unless converter.instance_of? md_class + return unless defined?(converter) && converter.instance_of?(md_class) # read and cache content of _references.md if @@refs_content.nil? diff --git a/generator/_scripts/_run_jekyll.sh b/generator/_scripts/_run_jekyll.sh index 97d2a93f0..176ac41c5 100755 --- a/generator/_scripts/_run_jekyll.sh +++ b/generator/_scripts/_run_jekyll.sh @@ -19,18 +19,6 @@ rm -rf $WRKDIR/documentation/generator/pages/generator find $WRKDIR/documentation/generator/pages -type f -name "*.markdown" -exec grep -l '^published: false$' {} + | xargs rm -f cd $WRKDIR/documentation/generator -# rvm commands are insane scripts which pollut output -# so instead of set -x we just echo each command ourselves -set +x -if [ -e "/home/jenkins/.rvm/scripts/rvm" ]; then - echo "+ /home/jenkins/.rvm/scripts/rvm" - source /home/jenkins/.rvm/scripts/rvm -elif [ -e "$HOME/.rvm/scripts/rvm" ]; then - echo "+ $HOME/.rvm/scripts/rvm" - source $HOME/.rvm/scripts/rvm -else - echo "ERROR: I couldn't source rvm from '/home/jenkins/.rvm/scripts/rvm' or '\$HOME/.rvm/scripts/rvm', probably jekyll won't work" -fi echo "Latest jekyll run :$BUILD_ID" > $WRKDIR/output.log echo "Based on latest git commit :$GIT_COMMIT" >> $WRKDIR/output.log @@ -38,7 +26,7 @@ echo "*********************************************************" >> $WRKDIR/outp echo "* CONSOLE OUTPUT *" >> $WRKDIR/output.log echo "*********************************************************" >> $WRKDIR/output.log set -x -jekyll +$(which jekyll) build if [ "$?" -gt "0" ]; then exit 1; fi diff --git a/generator/build/install.sh b/generator/build/install.sh index 224f9fba2..8a5d95bde 100644 --- a/generator/build/install.sh +++ b/generator/build/install.sh @@ -3,116 +3,43 @@ set -ex # All of these commands are executed by the jenkins user. - +sudo apt-get update && sudo apt-get upgrade sudo apt-get install -y curl gnupg2 wget git -# some of packages below depend on tzdata. Installing it without DEBIAN_FRONTEND=noninteractive causes it to ask where in the world are you, interrupting the build process +# some of packages below depend on tzdata. Installing it without DEBIAN_FRONTEND=noninteractive causes it to ask where +# in the world are you, interrupting the build process DEBIAN_FRONTEND=noninteractive sudo --preserve-env=DEBIAN_FRONTEND apt-get install -y tzdata # Docslave specifics # These packages are needed as a dependency of the nokogiri ruby gem (which in turn is a dependency of the sanitize ruby gem). -sudo apt-get install -y libxslt-dev libxml2-dev -# Python is needed for our pre and post processing scripts. +sudo apt-get install -y libxslt-dev libxml2-dev ruby ruby-dev rubygems build-essential python3 +echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc +echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc +echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc +source ~/.bashrc + +# Python is needed for our pre and post processing scripts. sudo apt-get install -y python3 -# These packages are needed to satisfy rvm requirements. +sudo apt-get install -y gawk g++ gcc autoconf automake bison libc6-dev libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev \ + libtool libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev libreadline-dev -# hint: to figure out rvm requirements, comment this line and watch output of `rvm install ... ruby`. -# To make script stop at that command, change --autolibs argument to read-fail. -# Also you likely will want to exclude 'libssl1.0-dev' since it's and openssl 1.0 library, which is not shipped on modern distros. -sudo apt-get install -y gawk g++ gcc autoconf automake bison libc6-dev libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev libreadline-dev +sudo apt-get install -y python3-pygments -# We currently use pygments for syntax highlighting. Jekyll 0.12.1 errors during install without this. +sudo apt-get install -y default-jdk -sudo apt-get install -y python3-pygments -# yui-compressor (ruby gem dependency) is written in java, so we need to install it. +sudo gem install jekyll jekyll_asset_pipeline jekyll-paginatege read_yaml closure-compiler bundler closure-compiler \ + yui-compressor albino execjs redcarpet uglifier sanitize -sudo apt-get install -y default-jdk +curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - && sudo apt-get install -y nodejs +$(which node) --version +$(which npm) --version +$(which jekyll) --version +$(which ruby) --version -## Install RVM and Ruby -## RVM helps us manage the ruby dependencies and ruby versions in a contained way. - -# Install mpapis public key (might need `gpg2` and or `sudo`) -#keyserver=keys.gnupg.net -keyserver=keyserver.ubuntu.com -gpg2 --keyserver hkps://$keyserver --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB - -echo "Downloading and installing Ruby Version Manager" -# Download the installer -curl -O https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer -curl -O https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer.asc - -if gpg2 --verify rvm-installer.asc; then - bash rvm-installer --autolibs=read-fail --ignore-dotfiles stable -else - echo "Ruby Version Manager signature check fail." - echo "Github is hacked, or trying to hack us, or our script is wrong. Aborting everything" - exit 1 -fi - -# rvm commands are insane scripts which pollut output -# so instead of set -x we just echo each command ourselves -set +x -echo "+ source ~/.rvm/scripts/rvm" -# shellcheck disable=SC1090 -source ~/.rvm/scripts/rvm - -echo "+ rvm_rubygems_version=none rvm install --autolibs=read-only ruby-1.9.3-p551 -C --without-openssl" -rvm_rubygems_version=none rvm install --autolibs=read-only ruby-1.9.3-p551 -C --without-openssl - -gem install jekyll --version 0.12.1 -gem install jekyll-asset-pipeline --version 0.1.6 -gem install closure-compiler --version 1.1.8 -gem install yui-compressor --version 0.9.6 -gem install albino --version 1.3.3 -gem install execjs --version 1.4.0 -gem install redcarpet --version 2.2.2 -gem install uglifier --version 1.3.0 -gem install sanitize --version 2.0.3 - -cat > /tmp/jekyll-0.12.1-cfengine.patch <> "$WRKDIR"/documentation/generator/_config.yml # so instead of set -x we just echo each command ourselves set +x -# since May 14 2019, we need this to run jekyll. IDK why. -echo "+ source ~/.rvm/scripts/rvm" -# shellcheck disable=SC1090 -source ~/.rvm/scripts/rvm -echo "+ rvm --default use 1.9.3-p551" -rvm --default use 1.9.3-p551 -echo "+ source ~/.profile" -ls -lah ~ -# shellcheck disable=SC1090 -test -f ~/.profile && source ~/.profile -echo "+ source ~/.rvm/scripts/rvm" -# shellcheck disable=SC1090 -source ~/.rvm/scripts/rvm - export LC_ALL=C.UTF-8 # finally, run actual jekyll