📜 ⬆️ ⬇️

We collect ProGit documentation, under Windows

Foreword


Good day.

For about six months, our company has moved from the 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 in our team wrote several internal articles with the main scenarios: the creation of brunch, merdzhi, etc.
But life presents its surprises and the exit for the main scenarios was always denoted by the phrase WTF or speaking Russian “I thought Git would do it, why did he do it differently?”

And it all came down to the fact that you need to read the documentation for the Gita. (And there is always no time to read the documentation.)
On this occasion, there was an article Completed the translation of the book "Pro Git" on Habré.
But as it turned out, the documentation is still being modified. Not often, but still, it is clearly visible when the latter were introduced.
')
And the idea to make 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. by linking to the 'https://github.com/progit/progit.git' repository


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

But then a surprise was waiting for me, the documentation was in an unknown markdown format, and in order to create an option for an 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 the documentation, was not pleasant. Perhaps there are other solutions, then only my bike.
Oh great internet! There in the open spaces, I managed to find a Pandoc utility that 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 when converting is simple

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

From the nuances:
  1. It was necessary to pick up when generating multiple files.
  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 was written in VBScript (I am not a guru of this language, I just needed to solve my problem). VBS is not so complicated and it was quite enough to solve it.

1. It is solved by searching all the files in the folder with the markdown extension.
2. Solved by RegExp.
Such 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. Where to run the script is important because it takes into account the path to the pictures.
  2. To build pdf you need latex, so I did not try 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, but one step closer :).


Links


Download dock

Source: https://habr.com/ru/post/158151/


All Articles