Skip to content

Commit

Permalink
Added Travis CI build configuration and scripts for generating docume…
Browse files Browse the repository at this point in the history
…ntation and pdf file. README updated to include links to documentation, dependencies, dependent libraries and mystery files as well the self-link. Added TravisCI badge to README.
  • Loading branch information
Konard committed Aug 13, 2019
1 parent 6a8f506 commit bddc769
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 3 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: csharp
sudo: required
dist: xenial
mono: latest
dotnet: 2.2
before_install:
- sudo apt-get install -y texlive texlive-lang-cyrillic texlive-latex-extra python-pygments ghostscript
- export TRAVIS_REPO_NAME=$(echo "${TRAVIS_REPO_SLUG#*/}" | sed 's/.*/\u&/')
script:
- dotnet build -c Release
after_success:
- bash ./generate-pdf.sh
- bash ./publish-docs.sh
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
[![Build Status](https://travis-ci.com/linksplatform/Reflection.svg?branch=master)](https://travis-ci.com/linksplatform/Reflection)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/af08bf638ea6420faccd181b331a5999)](https://app.codacy.com/app/drakonard/Reflection?utm_source=github.com&utm_medium=referral&utm_content=linksplatform/Reflection&utm_campaign=Badge_Grade_Dashboard)
[![CodeFactor](https://www.codefactor.io/repository/github/linksplatform/reflection/badge/master)](https://www.codefactor.io/repository/github/linksplatform/reflection/overview/master)

# Reflection
# [Reflection](https://github.com/linksplatform/Reflection)

LinksPlatform's Platform.Reflection Class Library.

Namespace: Platform.Reflection
Namespace: [Platform.Reflection](https://linksplatform.github.io/Reflection/api/Platform.Reflection.html)

Forked from: [Konard/LinksPlatform/Platform/Platform.Helpers/Reflection](https://github.com/Konard/LinksPlatform/tree/822c3c283cab152489d49e6a1727ca76f8595ce2/Platform/Platform.Helpers/Reflection)

NuGet package: [Platform.Reflection](https://www.nuget.org/packages/Platform.Reflection)
NuGet package: [Platform.Reflection](https://www.nuget.org/packages/Platform.Reflection)

## [Documentation](https://linksplatform.github.io/Reflection)
[PDF file](https://linksplatform.github.io/Reflection/Platform.Reflection.pdf) with code for e-readers.

## Depend on
* [Platform.Collections](https://github.com/linksplatform/Collections)

## Dependent libraries
* [Platform.Converters](https://github.com/linksplatform/Converters)
* [Platform.Helpers](https://github.com/linksplatform/Helpers)

## Mystery files
* [.travis.yml](https://github.com/linksplatform/Reflection/blob/master/.travis.yml) - Travis CI build configuration.
* [docfx.json](https://github.com/linksplatform/Reflection/blob/master/docfx.json) and [toc.yml](https://github.com/linksplatform/Reflection/blob/master/toc.yml) - DocFX build configuration.
* [format-document.sh](https://github.com/linksplatform/Reflection/blob/master/format-document.sh) - script for formating `tex` file for generating PDF from it.
* [format-csharp-files.py](https://github.com/linksplatform/Reflection/blob/master/format-csharp-files.py) - script for formating single `.cs` file as a part of `tex` file.
* [generate-pdf.sh](https://github.com/linksplatform/Reflection/blob/master/generate-pdf.sh) - script that generates PDF with code for e-readers.
* [publish-docs.sh](https://github.com/linksplatform/Reflection/blob/master/publish-docs.sh) - script that publishes generated documentation and PDF with code for e-readers to `gh-pages` branch.
* [push-nuget.bat](https://github.com/linksplatform/Reflection/blob/master/push-nuget.bat) - Windows script for publishing current version of NuGet package.
37 changes: 37 additions & 0 deletions docfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"metadata": [
{
"src": [
{
"files": [ "**/*.sln" ],
"exclude": [ "**/bin/**", "**/obj/**" ],
"src": ""
}
],
"dest": "obj/api"
}
],
"build": {
"content": [
{
"files": [ "**/*.yml" ],
"src": "obj/api",
"dest": "api"
},
{
"files": [ "*.md", "toc.yml" ]
}
],
"globalMetadata": {
"_appTitle": "LinksPlatform's Platform.$TRAVIS_REPO_NAME Library",
"_enableSearch": true,
"_gitContribute": {
"branch": "master"
},
"_gitUrlPattern": "github"
},
"markdownEngineName": "markdig",
"dest": "_site",
"xrefService": [ "https://xref.docs.microsoft.com/query?uid={uid}" ]
}
}
19 changes: 19 additions & 0 deletions format-csharp-files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
for line in sys.stdin.readlines():
line = line.strip()
print "\\index{%s}" % (line.replace('_','\\_'))
print "\\begin{section}{%s}" % (line.replace('_','\\_'))
#print "\\inputminted[tabsize=2,breaklines,linenos=true]{csharp}{%s}" % (line)
print "\\begin{minted}[tabsize=2,breaklines,breakanywhere,linenos=true,xleftmargin=7mm,framesep=4mm]{csharp}"
f = open(line,"rt")
c = "\n".join([x.strip("\n") for x in f.readlines()])
f.close()
c = c.replace(u'\ufeff','')
print c
print "\\end{minted}"
print "\\end{section}"
print
50 changes: 50 additions & 0 deletions format-document.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# Download fvextra package
wget https://raw.githubusercontent.com/gpoore/fvextra/cc1c0c5f7b92023cfec67084e2a87bdac520414c/fvextra/fvextra.sty

echo """
\\documentclass[11pt,a4paper,fleqn]{report}
\\usepackage[left=5mm,top=5mm,right=5mm,bottom=5mm]{geometry}
\\textwidth=200mm
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage[T2A]{fontenc}
\\usepackage{fvextra}
\\usepackage{minted}
\\usemintedstyle{vs}
\\usepackage{makeidx}
\\usepackage[columns=1]{idxlayout}
\\makeindex
\\renewcommand{\\thesection}{\\arabic{chapter}.\\arabic{section}}
\\setcounter{chapter}{1}
\\setcounter{section}{0}
\\usepackage[tiny]{titlesec}
\\titlespacing\\chapter{0mm}{0mm}{0mm}
\\titlespacing\\section{0mm}{0mm}{0mm}
\\DeclareUnicodeCharacter{221E}{\\ensuremath{\\infty}}
\\DeclareUnicodeCharacter{FFFD}{\\ensuremath{ }}
\\usepackage{fancyhdr}
\\pagestyle{fancy}
\\fancyhf{}
\\fancyfoot[C]{\\thepage}
\\renewcommand{\\headrulewidth}{0mm}
\\renewcommand{\\footrulewidth}{0mm}
\\renewcommand{\\baselinestretch}{0.7}
\\begin{document}
\\sf
\\noindent{\\Large LinksPlatform's Platform.${TRAVIS_REPO_NAME} Class Library}
"""

# Remove auto-generated code files
find ./obj -type f -iname "*.cs" -delete

# CSharp files
#find * -type f -iname '*.cs' -exec sh -c 'enconv "{}"' \;
find . -type f -iname '*.cs' | sort -b | python format-csharp-files.py

echo """
\\printindex
\\end{document}
"""
16 changes: 16 additions & 0 deletions generate-pdf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# Generate tex file
bash format-document.sh > document.tex

# Generate pdf
latex -shell-escape document.tex
makeindex document
latex -shell-escape document.tex
dvipdf document.dvi document.pdf
dvips document.dvi

# Copy pdf to publish location (with be used in the next script)
mkdir _site
cp document.pdf _site/Platform.${TRAVIS_REPO_NAME}.pdf
56 changes: 56 additions & 0 deletions publish-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# Settings
SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"
SHA=$(git rev-parse --verify HEAD)
COMMIT_USER_NAME="linksplatform-docs"
COMMIT_USER_EMAIL="[email protected]"
REPOSITORY="github.com/linksplatform/${TRAVIS_REPO_NAME}"

# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
echo "Skipping deploy."
exit 0
fi

# Insert repository name into DocFX's configuration files
sed -i "s/\$TRAVIS_REPO_NAME/${TRAVIS_REPO_NAME}/g" toc.yml
sed -i "s/\$TRAVIS_REPO_NAME/${TRAVIS_REPO_NAME}/g" docfx.json

# DocFX installation
nuget install docfx.console
mono $(ls | grep "docfx.console.")/tools/docfx.exe docfx.json

# Clone the existing gh-pages for this repo into out/
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
git clone https://$REPOSITORY out
cd out
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
cd ..

# Clean out existing contents
rm -rf out/**/* || exit 0

# Copy genereted docs site
cp -r _site/* out

cd out

# Do not use index.md
cp README.html index.html

# Now let's go have some fun with the cloned repo
git config user.name "$COMMIT_USER_NAME"
git config user.email "$COMMIT_USER_EMAIL"
git remote rm origin
git remote add origin https://$COMMIT_USER_NAME:$TOKEN@$REPOSITORY.git

# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add --all
git commit -m "Deploy to GitHub Pages: ${SHA}"

# Now that we're all set up, we can push.
git push https://$COMMIT_USER_NAME:$TOKEN@$REPOSITORY.git $TARGET_BRANCH
5 changes: 5 additions & 0 deletions toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- name: Home
href: README.md
- name: API Documentation
href: obj/api/
homepage: api/Platform.$TRAVIS_REPO_NAME.html

0 comments on commit bddc769

Please sign in to comment.