如何在 Ubuntu 上安装 Doxygen


Doxygen 是从带注释的 C++ 源代码生成文档的实际标准工具,但是,它也支持其他著名的编程语言,如 C、Objective-C、C#、超文本预处理器、Java、Python、IDL(Corba、Microsoft 和 UNO/OpenOffice 版本)、Fortran、VHDL 和 Tcl。本文解释了“如何在 Ubuntu 上安装 Doxygen”

要安装 Doxygen,请使用以下命令 –

$ sudo apt-get install doxygen

示例输出应如下所示 –

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
   libterm-readkey-perl linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic
   linux-image-4.4.0-31-generic linux-image-extra-4.4.0-31-generic
   linux-signed-image-4.4.0-31-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
   libclang1-3.6 libllvm3.6v5 libobjc-5-dev libobjc4
Suggested packages:
   doxygen-latex doxygen-doc doxygen-gui graphviz
The following NEW packages will be installed:
   doxygen libclang1-3.6 libllvm3.6v5 libobjc-5-dev libobjc4
0 upgraded, 5 newly installed, 0 to remove and 26 not upgraded.
Need to get 15.9 MB of archives.
After this operation, 64.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libllvm3.6v5 amd64 1:3.6.2-3ubuntu2 [8,075 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libobjc4 amd64 5.4.0-6ubuntu1~16.04.4 [111 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libobjc-5-dev amd64 5.4.0-6ubuntu1~16.04.4 [380 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libclang1-3.6 amd64 1:3.6.2-3ubuntu2 [3,696 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 doxygen amd64 1.8.11-1 [3,679 kB]
.........................................................................................

要获取有关 Doxygen 的更多信息,请使用以下命令 –

$ doxygen --help

示例输出应如下所示-

Doxygen version 1.8.11
Copyright Dimitri van Heesch 1997-2015

You can use doxygen in a number of ways:

1) Use doxygen to generate a template configuration file:
   doxygen [-s] -g [configName]

   If - is used for configName doxygen will write to standard output.

2) Use doxygen to update an old configuration file:
   doxygen [-s] -u [configName]

3) Use doxygen to generate documentation using an existing configuration file:
   doxygen [configName]

   If - is used for configName doxygen will read from standard input.

4) Use doxygen to generate a template file controlling the layout of the
generated documentation:
   doxygen -l [layoutFileName.xml]

5) Use doxygen to generate a template style sheet file for RTF, HTML or Latex.
   RTF: doxygen -w rtf styleSheetFile
   HTML: doxygen -w html headerFile footerFile styleSheetFile [configFile]
   LaTeX: doxygen -w latex headerFile footerFile styleSheetFile [configFile]

6) Use doxygen to generate a rtf extensions file
   RTF: doxygen -e rtf extensionsFile
........................................................................

若要生成源代码,请使用以下代码-

$ doxygen -g sample_text.conf

在上一个命令中,它生成了一个名为 sample_text.conf 的文件,其中包含以下所示代码 –

# Doxyfile 1.8.11

# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
#
# All text after a double hash (##) is considered a comment and is placed in
# front of the TAG it is preceding.
#
# All text after a single hash (#) is considered a comment and will be ignored.
# The format is:
# TAG = value [value, ...]
# For lists, items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (\" \").

#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------

..................................................................................

要生成文档,请使用以下命令 –

$ doxygen sample_text.conf

示例输出应如下所示 –

Searching for include files...
Searching for example files...
Searching for images...
Searching for dot files...
Searching for msc files...
Searching for dia files...
Searching for files to exclude
Searching INPUT for files to process...
Searching for files in directory /home/linux
warning: source /home/linux/.dbus is not a readable file or directory... skipping.
Reading and parsing tag files
Parsing files
Preprocessing /home/linux/abc.txt...
Parsing file /home/linux/abc.txt...
Preprocessing /home/linux/bbc.txt...
Parsing file /home/linux/bbc.txt...
Building group list...
Building directory list...
Building namespace list...
Building file list...
Building class list...
Associating documentation with classes...
Computing nesting relations for classes...
Building example list...
Searching for enumerations...
Searching for documented typedefs...
Searching for members imported via using declarations...
Searching for included using directives...
Searching for documented variables...
Building interface member list...
................................................................

若要浏览 HTML 格式的文档,请使用以下命令 –

$ cd html
/html$ google-chrome index.html

示例输出应如下所示 –

在阅读本文后,你将能够理解 – 如何在 Ubuntu 上安装 Doxygen。在我们的下一篇文章中,我们将提供更多基于 Linux 的技巧和提示。继续阅读!

更新于: 2020 年 1 月 20 日

12K+ 浏览量

开启职业生涯

通过完成课程获取认证

开始学习
广告
© . All rights reserved.