We collect documentation ProGit, under Windows

Foreword


Good afternoon.

For about six months now, our company has switched from SVN version control system to Git. I will not write about the advantages or disadvantages, they have been discussed more than once. The guys who did this on our team wrote several internal articles with the main scenarios: creating brunches, merges, etc.
But life brings its surprises and going beyond the main scenarios has always been indicated by the phrase WTF or, in Russian, “I thought Git would do it, why did it do it differently?”

And it all came down to the fact that you need to read the documentation on the Geeta. (And reading documentation, there is always no time.)
On this occasion, the article was completed Translation of the book "Pro Git" on the hub
But as it turned out, the documentation is still being amended. Not often, but still,here it is clearly visible when the latter were introduced.

And the idea came up to mold the last version of the docks ...

Git + Pandoc + Windows


To do this, we need to install Git Extensions , in the Commands menu, select Clone Repository. pointing to the repository link 'https://github.com/progit/progit.git'


And click Clone.
PS To download docks, anonymous access is used, so no keys will be required.

But then a surprise awaited me, the documentation was in an unknown markdown format, and in order to create an option for EBook, it was suggested to do this:

Making Ebooks
On Fedora you can run something like this:

$ yum install ruby calibre rubygems ruby-devel rubygem-ruby-debug
$ gem install rdiscount
$ makeebooks en  # will produce a mobi

The prospect of setting up a Linux virtual machine, just to collect documentation, was not pleasing. Perhaps there are other solutions, then just my bike.
Oh great internet! There, in the vast, I managed to find the Pandoc utility , which can turn markdown format files into docx, pdf, txt, etc.
Features and syntax can be found here .
Download, install, go to the folder E: \ sources.git \! \ Progit \ ru
If you look, the syntax for converting is simple

pandoc -S  01-introduction\01-chapter1.markdown -o gitbook.docx

From the nuances:
  1. It was necessary to pick up several files during generation.
  2. The links to the pictures were indicated in the format
     Insert 18333fig0101.png
     Рисунок 1-1. Схема локальной СУВ.
    
    , but you must
    ![ Рисунок 1-1. Схема локальной СУВ.](..\figures\18333fig0101-tn.png)
    


Therefore, I wanted to automate the process and VBScript was written (I am not a guru of this language, I just needed to solve my problem). VBS is not so complicated and it was enough to solve it.

1. It is solved by searching for all files in a folder with the markdown extension.
2. Solved using RegExp.
This script will turn out:
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objRegEx = CreateObject("VBScript.RegExp")
Dim sCurPath, tempFolder, files
sCurPath = objFSO.GetAbsolutePathName(".")
tempFolder = sCurPath + "\!"
if objFSO.FolderExists(tempFolder) then
    objFSO.DeleteFolder(tempFolder)
end if
objFSO.CreateFolder(tempFolder)
CopyFiles sCurPath, tempFolder
Dim cmd
cmd = "pandoc -S " + files + " -o gitbook.docx"
with createobject("wscript.shell")
  .Run(cmd), 0, True
end with
WScript.Echo("Completed")
Function CopyFiles(CurrentFolderName, TempFolderName)
    On Error Resume Next
    Dim ObjFolder
    Dim ObjSubFolders
    Dim ObjSubFolder
    Dim ObjFiles
    Dim ObjFile	
    Set ObjFolder = objFSO.GetFolder(CurrentFolderName)
    Set ObjFiles = ObjFolder.Files
    For Each ObjFile In ObjFiles
    IF objFSO.GetExtensionName(ObjFile.name) = "markdown" Then
        Set openedFile = objFSO.OpenTextFile(ObjFile.Path, ForReading)
        Set outputfile = objFSO.CreateTextFile(TempFolderName + "\" + ObjFile.name, True)
        files = files + "!\" + ObjFile.name + " "
        objRegEx.IgnoreCase = True
        objRegEx.MultiLine = True
        objRegEx.Global = True
        objRegEx.Pattern = "Insert (.*).png\n*\s*(.*)$"
        text = openedFile.ReadAll
        openedFile.Close
        result = objRegEx.Replace(text, "![$2](../figures/$1-tn.png)")
        outputfile.Write result
        outputfile.Close
    End If
    Next
    'Getting all subfolders
    Set ObjSubFolders = ObjFolder.SubFolders
    For Each ObjFolder In ObjSubFolders
        'Getting all Files from subfolder
        CopyFiles ObjFolder.Path, TempFolderName
    Next
End Function


Run the script from the folder E: \ sources.git \! \ Progit \ ru , we get gitbook.docx .

Conclusion


  1. The place from where to run the script is important, since the path to the pictures is taken into account.
  2. To build pdf you need latex, so I have not tried it.
  3. If the file is needed in a different format, you can already use other utilities to convert docx to pdf, fb2, etc ...
  4. I didn’t start reading the documentation like that, but it’s one step closer :).


Links


Download Doc

Also popular now: