Lazarus Documentation Editor/pl

From Lazarus wiki
Revision as of 13:53, 22 June 2019 by Slawek (talk | contribs) (Druga część tłumaczenia)
Jump to navigationJump to search

Deutsch (de) English (en) español (es) français (fr) 日本語 (ja) polski (pl) русский (ru) slovenčina (sk)

Wprowadzenie

Dobra, wszechstronna dokumentacja jest ważną brakującą częścią Lazarusa. Aby pomóc w opracowaniu potrzebnej dokumentacji, opracowano narzędzie o nazwie LazDE. Ta strona opisuje użycie tego narzędzia do edycji istniejącej dokumentacji lub do tworzenia nowych plików dokumentacji. W tym dokumencie wiki używam [$LazDir] do oznaczenia ścieżki do katalogu bazowego Lazarusa. Więc kiedy znajdziesz w tekście [$LazDir], po prostu zastąp go ścieżką odpowiednią dla instalacji Lazarusa w twoim systemie.

Uzasadnienie

Głównym celem tego projektu dokumentacji jest udostępnienie pliku pomocy online. Aby stworzyć pliki pomocy niezależne od platformy, używamy plików XML do rejestrowania i przechowywania danych dokumentacji. Każda jednostka Lazarusa ma swój własny plik danych XML.

Duża liczba takich plików XML została już napisana i można ich użyć:

  • do stworzenia stron HTML, które możesz przeglądać na http://lazarus-ccr.sourceforge.net/docs/lcl/
  • do stworzenia plików CHM, które możesz przeglądać w trybie offline (po umieszczeniu w poprawnie zarejestrowanym katalogu lokalnym) jako pomoc dla Lazarus, która jest dostępna nawet wtedy, gdy nie masz dostępu do Internetu.

Tworzenie dokumentacji w praktyce

Jak wspomniano powyżej, XML został wybrany jako format danych dokumentacji, ponieważ jest niezależny od platformy. Aktualną dokumentację można znaleźć w [$LazDir]/docs/xml/. Do tej pory w katalogu /lcl/ znajdują się głównie puste pliki szkieletu, które zawierają niewiele (lub nie zawierają) użytecznej dokumentacji. Pliki XML, które znajdziesz w tym katalogu, są generowane automatycznie i wymagają dostosowania, aby były użyteczne. Teraz gdy wiemy, gdzie znaleźć te pliki, spójrzmy na narzędzie, które zastosujemy aby stworzyć i dostosować pliki danych dokumentacji.

Narzędzie do edycji dokumentacji Lazarusa

„Lazde” jest narzędziem przeznaczonym do edycji plików dokumentacji XML. Można go również użyć do wygenerowania podstawowego szkieletu pliku XML pochodzącego ze źródłowego pliku modułu (unit) Pascala i (za pomocą zewnętrznego narzędzia FPDoc) do wygenerowania wersji HTML dokumentacji. Przykład wyniku działania FPDoc można zobaczyć tutaj. Jest to część dotychczas utworzonej dokumentacji. Ponieważ skompilowane wersje wykonywalne programu lazde nie są dostarczane, musisz go zbudować dla siebie. Pliki źródłowe „lazde” można znaleźć w [$LazDir]/doceditor/. Po zbudowaniu i uruchomieniu tego programu oraz po otwarciu pliku [$LazDir]/docs/xml/lcl/dialogs.xml zostanie wyświetlony ten ekran

Lazdemain.png

Dokumentowanie LCL

Lazdeelements.png

Otwarcie węzła „Pakiety” pokazuje węzeł „LCL”, który zawiera węzeł „Dialogs” (Okna dialogowe). Wybranie tego ostatniego węzła wypełnia dolny widok drzewa elementami. Te elementy zawierają listę stałych, typów i klas zdefiniowanych w module dialogs.pp. Wszelkie moduły używane przez dialogs.pp są również dodawane jako kolejne węzły. Inne węzły są dodawane dla właściwości klasy, parametrów funkcji i procedur i tak dalej.

Wybranie węzła w lewym dolnym widoku drzewa wyświetla zawartość tego węzła po prawej stronie okna.

Gdy spojrzysz na tę stronę, zobaczysz przegląd klas zdefiniowanych w module „dialogs”. Po każdej nazwie klasy zobaczysz linię tekstu, którą została wpisana w „krótkie” pole edycyjne lazde.

Poniżej „krótkiego” pola edycji znajduje się pole notatnika (memo), w którym można wprowadzić dłuższy opis komponentu lub właściwości.

Light bulb  Uwaga: Jeśli chcesz wstawić znak podziału wiersza użyj <br/>

Below the main description field are further fields labelled "Errors", "See also" and "Example code File".

"Errors" is used to give information about any errors raised by a function if parameters have values that are out of range. For an example see this page.

The "See also" and "Example code File" fields are each provided with three buttons ([+], [^], [-]). These buttons enable you to add and remove links to other pages or code examples respectively.

The Outcome

Have a look at the description of InputQuery. At the top of the page you can see what the page is about (in this case the InputQuery function from dialogs.pp). The first line of text is what has been entered in the "Short" editbox in lazde.

Next is the declaration of this function taken from the source file dialogs.pp. The declaration part is created by the html-builder and is parsed directly from the sources. Because there are two versions of this function the source position says 0.

Then the arguments are given. When you open the InputQuery node in lazde you will see each argument separately as a child node. The text shown after each argument corresponds to whatever was entered in the "Short" editbox when the respective child node was selected.

The function result is shown as a fourth paragraph. The text shown here has been entered in the same way as for the function's arguments.

Lastly the description is shown. This is the text entered in the description box of lazde.

Adding documentation for new units

There are of course many other units waiting to be documented. If the unit is part of a package, it is likely that there is no xml file for you to start from. You will then have to start from scratch, and lazde has a function to get you off to a flying start. Just go to File -> New and the following screen appears:

Lazdenewdocfromfile.png

You start by naming the package. All units you want to add to this package should be given the same package name. Afterwards you enter the source file to use. You can browse to this file as well. Then enter a name for the output file - do not forget the xml extension! - and click OK.

lazde will then generate the skeleton documentation. The generated file will be opened and the treeview will be populated with all the units, classes, types, functions and so on from your source file. Now you are ready to start documenting a new part of Lazarus.

Have a look at LCL Documentation Roadmap to see which units still need to be documented.

You can use FPDoc Updater to easily update FPDoc files when Pascal units have been changed.

The Final result

What I experienced during the use of the program is that I would like to see how the information is shown in its final stage (as a browsable document). For this purpose lazde makes use of a utility to build all necessary HTML-files.

This utility can be started from the menu Extra -> Build. The following screen will be shown:

Lazdebuild1.png

"Package" should be the same as the name you gave when you created the xml files. For "Format" choose HTML. At "Output" you enter the path where the resulting files should be placed. Press "Add all" and all documents your were working on will be added to the project. Then go to the next to tab

Lazdebuild2.png

and enter the paths to the source files. After you have pressed build your HD will start to rattle and finally the following output will be shown on the "Build output" tab.

Building docs using command: fpdoc --package="LCL"
--output="/home/matthijs/documentatie/LCL" --format=html --content 
--descr="/home/matthijs/Projecten/Lazarus/doceditor/buttons.xml"
--descr="/home/matthijs/Projecten/Lazarus/doceditor/comctrls.xml"
--descr="/home/matthijs/Projecten/Lazarus/doceditor/dialogs.xml"
--descr="/home/matthijs/Projecten/Lazarus/doceditor/controls.xml"
--input="/home/matthijs/cvsroot/lazarus/lcl/buttons.pp"
--input="/home/matthijs/cvsroot/lazarus/lcl/comctrls.pp"
--input="/home/matthijs/cvsroot/lazarus/lcl/dialogs.pp"
--input="/home/matthijs/cvsroot/lazarus/lcl/controls.pp" 

FPDoc - Free Pascal Documentation Tool
(c) 2000 - 2003 Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org

Writing 2788 pages...
Done.
Documentation successfully built.

When you go to the directory you entered at "Output" you will see a index.html file and (in this case 4) sub directories. Open index.html in your favorit browser and see the result of all your hard work on the documentation. You will be able to follow the links and read it all.

When you plan to continue working on this package of documentation, press "Save" and save the build options. You will be asked to provide a name for the file and the options will be saved. Next time you want to build the HTML-files you can just "load" them again.

Submitting your work

When you are satisfied with your work on Lazarus' documentation, you certainly want to share it with the Lazarus community. All you have to do is make a patch, zip the patch and send it in.

Improvements welcome

Light bulb  Uwaga: lazde is a work-in-progress. It does work, but it's certainly not completely finished yet. You may encounter bugs. Feel free to fix them!