Skip to content

Commit

Permalink
Merge pull request #35 from owncloud/11.8-1afc432-34
Browse files Browse the repository at this point in the history
[11.8] [PR 34] Fix the family directory structure
  • Loading branch information
mmattel authored Jan 10, 2022
2 parents 2f892b0 + 798f268 commit 5aa4fc3
Show file tree
Hide file tree
Showing 76 changed files with 36 additions and 29 deletions.
2 changes: 1 addition & 1 deletion antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Mobile App for iOS (iOS 11+)
version: '11.8'
start_page: ROOT:index.adoc
nav:
- modules/ROOT/nav.adoc
- modules/ROOT/partials/nav.adoc

asciidoc:
attributes:
38 changes: 16 additions & 22 deletions bin/find-orphaned-adoc-files
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env bash

#
# This script checks which .adoc files are possibly orphaned.
# This script checks which .adoc files are possibly orphaned
# It can cover single and multi manual environments
#
# Note that filenames MUST NOT contain blanks

AVAILABLE_MANUALS=( ROOT )
# dependend of root or not, the manual name gets a postfix added, name see below
ROOT_NAME="ROOT"
# all main nav files from the modules have the name nav.adoc
NAV_FILENAME="nav.adoc"
NAV_ROOT_FILENAME="nav_root.adoc"
PARTIALS_NAME="_partials"
PARTIALS_NAME="partials"
# https://docs.antora.org/antora/2.3/page/resource-id/#id-coordinates
FAMILY='{partialsdir}'
#FAMILY="partial$"
MANUAL_NAME=
Expand Down Expand Up @@ -70,8 +72,13 @@ function usage()

function find_orphans()
{
local search_pattern=

validate_manual "$MANUAL_NAME"

# escape the dollar sign in the search pattern if exists
search_pattern="include::${FAMILY//$/\\$}"

# define the global variables
# the base directory name depends if there is a single or are multiple manuals available
if [[ ${MANUAL_NAME} = ${ROOT_NAME} ]]; then
Expand All @@ -81,25 +88,12 @@ function find_orphans()
fi
#
PAGES_DIR="${BASE_DIR}/pages"
#
# the nav file name and location depends if there are single or multiple manuals available
# and if the ROOT manual has been selected or not
#
# single manual
NAV_FILE="${BASE_DIR}/${NAV_FILENAME}"
#
# multi manual (overwrites the variable)
if [[ ${#AVAILABLE_MANUALS[@]} -gt 1 ]]; then
if [[ ${MANUAL_NAME} = ${ROOT_NAME} ]]; then
# ROOT selected
NAV_FILE="${BASE_DIR}/${NAV_ROOT_FILENAME}"
else
# another module selected
NAV_FILE="${PAGES_DIR}/${PARTIALS_NAME}/${NAV_FILENAME}"
fi
fi

# define the navigation file
NAV_FILE="${BASE_DIR}/${PARTIALS_NAME}/${NAV_FILENAME}"

# --> important: the partials dir may change to base_dir/partials_name
PARTIALS_DIR="${PAGES_DIR}/${PARTIALS_NAME}"
PARTIALS_DIR="${BASE_DIR}/${PARTIALS_NAME}"

# get content for all partials but exclude the nav file, however we call it
# partials directory may not be present
Expand Down Expand Up @@ -221,7 +215,7 @@ function find_orphans_for_manual()
# now check if there are orphaned partials files

# get all files which have an include + family statement
include_list=($(cat "${PAGES_FILES[@]/#/${PAGES_DIR}/}" | grep "include::${FAMILY}" | sort | uniq))
include_list=($(cat "${PAGES_FILES[@]/#/${PAGES_DIR}/}" | grep "${search_pattern}" | sort | uniq))
#echo ${include_list[@]} | tr ' ' '\n'
#exit

Expand Down
6 changes: 5 additions & 1 deletion bin/find-orphaned-base
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
exit
fi

# escape the dollar sign in the search pattern if exists
SEARCH_PATTERN="${SEARCH_PATTERN//$/\\$}"

function start_scan()
{
local list
Expand Down Expand Up @@ -92,8 +95,9 @@ function start_scan()
fi

# create an array diff and print to output
# the output contains the full relative path
not_linked=($(echo ${found_find[@]} ${found_grep[@]} | tr ' ' '\n' | sort | uniq -u))
echo ${not_linked[@]} | tr ' ' '\n'
echo "${not_linked[@]/#/${BASE_DIR}/${TARGET_DIR}/}" | tr ' ' '\n'

# count the number of occurrences
count_not_linked=$(( $count_not_linked + ${#not_linked[@]} ))
Expand Down
2 changes: 2 additions & 0 deletions bin/find-orphaned-example-files
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ TASK="EXAMPLE"
TARGET_DIR="examples"
# depending on the target, there may be a trailing slash necessary or not
# check how the file is included
# https://docs.antora.org/antora/2.3/page/resource-id/#id-coordinates
SEARCH_PATTERN='include::{examplesdir}'
#SEARCH_PATTERN='include::example$'

# get the full path the the directory the script runs
DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
Expand Down
3 changes: 2 additions & 1 deletion bin/find-orphaned-image-files
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ AVAILABLE_MANUALS=( ROOT )
ROOT_NAME="ROOT"
BASE_DIR=""
MANUAL_POSTFIX="_manual"
TARGET_DIR="assets/images"
TARGET_DIR="images"
# depending on the target, there may be a trailing slash necessary or not
# check how the file is included
# https://docs.antora.org/antora/2.3/page/resource-id/#id-coordinates
SEARCH_PATTERN='image:'

# get the full path the the directory the script runs
Expand Down
14 changes: 10 additions & 4 deletions bin/makepdf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ ACTUAL_BRANCH_NAME=
DEFAULT_NAME="next"
MASTER_BRANCH="master"

# the name of the partials directory
PARTIALS_NAME="partials"

DRY_RUN=false

# get the todays date
Expand Down Expand Up @@ -125,7 +128,7 @@ function clean_build_dir()
# the nav file is handed over as parameter used as stream
function convert_antora_nav_to_asciidoc_list()
{

local level_offset=
local nav_filename="$1"

# have a blank line between the template content end and the beginning of the inserts
Expand All @@ -140,7 +143,10 @@ function convert_antora_nav_to_asciidoc_list()
# on single manual repos, the level offset is corrected with 1 (NF-1)
level_offset=$(echo "$line" | awk -F"*" '{print NF-1}')
fi
revised_line=$(echo "$line" | sed 's/xref:/include::{module_base_path}/' | sed 's/\[.*\]//g' | sed -r 's/^\*{1,} //')
# when having multi manual repos, the last sed in the line below is to remove
# the manual component (:manual_name:) from the string
# this is because we have moved the nav.adoc file into partials and therefore need to add the module
revised_line=$(echo "$line" | sed 's/xref:/include::{module_base_path}/' | sed 's/\[.*\]//g' | sed -r 's/^\*{1,} //' | sed -e 's/\(module_base_path}\)\(.*:\)/\1/')
echo "${revised_line}[leveloffset=+${level_offset}]"
echo
fi
Expand Down Expand Up @@ -211,7 +217,7 @@ function build_pdf_manual()
local book_file="${BOOKS_DIRECTORY}/ownCloud_${manual_infix}_Manual.adoc"

# the navigation file for the manual to be built
local nav_file="modules/${source_root}/nav.adoc"
local nav_file="modules/${source_root}/${PARTIALS_NAME}/nav.adoc"

# Get the dynamic list of attributes from yml files
# The output after sed is a string like -a key=value -a key=value ...
Expand Down Expand Up @@ -261,7 +267,7 @@ function build_pdf_manual()
param+='-a format="pdf" '
# param+='-a experimental="" ' # experimental already set in site.yml
param+='-a examplesdir='$(pwd)/modules/${source_root}/examples/' '
param+='-a imagesdir='$(pwd)/modules/${source_root}/assets/images/' '
param+='-a imagesdir='$(pwd)/modules/${source_root}/images/' '
param+='-a partialsdir='$(pwd)/modules/${source_root}/pages/_partials/' '
param+='-a revnumber='${branch}' '
param+='-a revdate="'${release_date}'" '
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
Empty file added modules/ROOT/partials/.gitkeep
Empty file.
File renamed without changes.

0 comments on commit 5aa4fc3

Please sign in to comment.