What is the QHG_LOCATION path relative to for doxygen? - qt

When I set QHG_LOCATION to be an absolute path, I can create a valid doxygen documentation in html and qch. If I put qhelpgenerator and its DLLs into the current directory ./ and set QHG_LOCATION=qhelpgenerator, it also works. But I cannot figure out how to put the qhelpgenerator into a subdirectory qt/bin/qhelpgenerator and have doxygen find it. It always says
error: failed to run qhelpgenerator on index.qhp
which means that it could not find qhelpgenerator.
So the question is: If I want QHG_LOCATION to be a relative path, what directory is it relative to? It is neither relative to ./ nor to the html output directory.

Debugging the problem can be done by outputting the external commands executed:
doxygen -d extcmd and execute the given command 'by hand' outside of doxygen.
From the documentation of QHG_LOCATION:
The QHG_LOCATION tag can be used to specify the location of Qt's qhelpgenerator. If nonempty
doxygen will try to run qhelpgenerator on the generated .qhp file.
and from the documenattion of QCH_FILE:
If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify the file name of
the resulting .qch file. The path specified is relative to the HTML output folder.

Indeed, both QHG_LOCATION and QCH_FILE must be relative to the HTML output directory. Furthermore, you must use backslashes \ as directory separators on Windows. Forward slashes are supported in the rest of the doxyfile but not here.
I find both issues quite irritating, but this is the way it is.
Thanks to albert for a helpful comment!

Related

How can I change PATH variable in zsh?

I want to change my PATH variable in zsh.
Problem: I don't understand where in the .zshrc file I have to make modifications.
Normally, I would look for the assignment to the PATH variable and set the values from scratch how I would like them to be (leaving all the systems binaries directories untouched).
The first lines in my .zshrc file are as follows:
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/Sam/oh-my-zsh"
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/13/bin
etc.
My actual PATH variable is:
/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/13/bin
I want to delete the directory where python3.8 is in, it's redundant.
My questions:
Do I have to change line 2 or line 7 in my .zshrc file?
Line 2 is commented out...is it executed anyway at the start of the terminal?
I have tried to comment out line 7. But the postgres directory still remained in my PATH variable which I don't understand.
The .zshrc is located in the home dir. The dot at the beginning keeps it hidden. Type ls -a from ~ directory to see it. To edit just run vim, nvim, etc as usual.
nvim ~/.zshrc
This is the command for Neovim. For your editor, sub nvim for the proper command.
Once you get in, you need only add the same export command that you would add from the command line.
export PATH=$PATH:/whatever/you/are/adding
EDIT
To remove a path variable:
First, run the command:
echo $PATH
from the command line.
Next, Copy the output to clipboard.
Finally, at the very end of the .zshrc file, add the following:
export PATH=<paste-what-you-copied-here>
Because you didn't reference $PATH after the =, this will set the path to EXACTLY what you pasted, no more, no less. Adding $PATH: as in the first example will just add whatever to the end of what is already there.
Since this gives you access to every item in the path array, deleting is just a matter of a literal highlight/select and of whatever you want deleted.
Finally, be sure that there is only one place in the file where you are editing PATH. If there are more than one, the result can be confusing to say the least.
That said, I believe the script runs top-to-bottom, so only the last mention should persist. You can take advantage of this in some situations, but for this purpose, one will suffice. XD
Be careful when you decide to fiddle with the PATH in .zshrc: Since the file is processed by every interactive subshell, the PATH would get longer and longer for each subshell, with the same directory occuring in it several times. This can become a nightmare if you later try to hunt down PATH-related errors.
Since you are using zsh, you can take advantage that the scalar variable PATH is mirrored in the array variable path, and that you can ask zsh to keep entries in arrays unique.
Hence, the first thing I would do is put a
typeset -aU path
in your .zshrc; this (due to mirroring) also keeps the entries in PATH unique. You can put this statement anywhere, but I have it for easier maintenance before my first assignment to PATH or path.
It is up to you to decide where exactly you add a new entry to PATH or path. The entries are searched in that order which is listed in the variable. You have to ask yourself two questions:
Are some directories located on a network share, where you can sometimes expect access delays (due to bad network conditions)? Those directories should better show up near the end of the path.
Do you have commands which occur in more than one directoryin your path? In this case, a path search will always find the first occurance only.
Finally, don't forget that your changes will be seen after zsh processes the file. Therefore, you could create a new subshell after having edited the file, or source .zshrc manually.

Relative directory path GNU make

I have defined a source.mk with include path at make for header files. I have to give the absolute file path to INCLUDES or an error of file not found appear.
# Add your include paths to this variable
INCLUDES = -I/home/ecee/C1M1-Abubaker/include/common \
my make file is in :
~/home/ecee/C1M1-Abubaker/
and the header file need to be included in :
~/home/ecee/C1M1-Abubaker/include/common
The question is how to find a path dynamically from another directory.
You can use the realpath make function:
$(realpath names…)
For each file name in names return the canonical absolute name. A canonical name does not contain any . or .. components, nor any repeated path separators (/) or symlinks. In case of a failure the empty string is returned. Consult the realpath(3) documentation for a list of possible failure causes.
In your case, that would probably be $(realpath include/common).
The OP said
… or an error of file not found appear
Something like:
mustexist = $(or $(realpath $1),$(error Path [$1] does not exist!))
1.o: 1.cpp
gcc -I$(call mustexist,${INCLUDES}) $< -o $#
If $(realpath …) expands to nothing (the path does not exist),
then make expands the $(error …) and the build stops.
As a refinement,
if ${INCLUDES} can expand to more than one folder (as implied by its name),
then you should test each path individually.
mustexist = $(or $(realpath $1),$(error Path [$1] does not exist!))
includes = $(foreach _,$1,-I$(call mustexist,$_))
1.o: 1.cpp
gcc $(call includes,${INCLUDES}) $< -o $#
To search for file in a directory above you can use -I./include/commonand for two directories above: -I../include/common
Below suggestion is the straightforward approach to add one folder.
Try like this, this should solve your problem.
INCLUDES:=/home/ecee/C1M1-Abubaker/include/common
<compiler and your source files> -I../$(realpath $(INCLUDES))

How to get absolute path on a zsh prompt?

I'm switching from bash to zsh.
I want to update my new zsh prompt and looked around to find a way, but I have only found "solutions" via oh-my-zsh.
The goal:
Location: ~/dir_1/dir_1_1/dir_1_1_1
What I have:
Location: dir_1_1_1
The code (source):
PS1='${SSH_CONNECTION+"%{$fg_bold[green]%}%n#%m:"}%{$fg_bold[green]%}Location: %c%{$reset_color%}$(git_prompt_info) '
To preserve original prompt format (colors, git info and potentially other customisations before this one) except related to path info, you could append following to the end of ~/.zshrc:
PROMPT=${PROMPT/\%c/\%~}
As pointed out by #caleb-adams and #fend25 the key is replacing %c (just folder name) with %~ to include full path (or absolute from $HOME when under ~). See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html for more info
As Horacio Chavez mentioned in the comment above, you want to look here: http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html for the details on how to change your displayed path in zsh.
In this case if you are looking for a path that is relative to your home folder, include a %~ in your zsh-theme file. Your prompt would now look like this:
PS1='${SSH_CONNECTION+"%{$fg_bold[green]%}%n#%m:"}%{$fg_bold[green]%}Location: %~%{$reset_color%}$(git_prompt_info) '
note, I only changed one character in your prompt. the %c was swapped for the %~. %c will only give your current directory (see the document link above, or here)
For a full path you could use %/
Simplest way to add bash-style dir path to the prompt. Just add this to ~/.zshrc:
setopt PROMPT_SUBST
PROMPT='%n#%m: ${(%):-%~} '
The part with the path is ${(%):-%~}. Colouring could be added according with your lifestyle:)

Setting path in bash_profile

Why does setting a PATH require the :${PATH} at the end?
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
When I append a path to this I would do
PATH=$PATH:...
How do I append a PATH without going to a new line. That is, how would I append a PATH to the original PATH statement.
If I wanted to put the following all in the first line, for instance. How does this interact with the :${PATH} part?
PATH=$PATH:/usr/local/mysql/bin
There's a difference between appending an existing path to the front or the end of the $PATH environment variable. The way bash resolves execution paths is by starting from the front of the list. That means if you have these two directories in your path:
PATH="/dir1/bin:/dir2/bin"
And they both have the executable test.sh in it, then when you run test.sh, it'll execute the one in /dir1/bin/test.sh since that directory appears first in the path.
Additionally, ${PATH} is the same as $PATH.
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
is simply adding /Library/Frameworks/Python.framework/Versions/2.7/bin to the front of the path and
PATH=$PATH:/usr/local/mysql/bin
is simply adding /usr/local/mysql/bin to the end of the path.
So how do you do both in one line? Something like this:
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:/usr/local/mysql/bin"

Absolute path to Relative Path in Unix

This command was to list only the text files in my fileAsst directory:
ls ~/UnixCourse/fileAsst/*.txt
now I need to do the same thing but using a relative path instead, what I've tried so far is:
ls ~/UnixCourse/../*.txt
but it's saying I'm not getting the right answer, can anyone give me some hints or explain the differences between a relative path and absolute path, because I still dont under it.
Relative is always, well, relative to some existing directory, you are currently "located" in (by means of the cd command, usually). In your question you don't show what the current directory is. So there is no single "correct" answer.
If your current directory is, say, ~ (which is just a shortcut for your home directory, for example, /home/myuser), then you're relative ls command would look like (I'm adding the implied previous cd command for clarity):
cd ~
ls UnixCourse/fileAsst/*.txt
likewise if your current directory is ~/UnixCourse, then your relative ls command would look like:
cd ~/UnixCourse
ls fileAsst/*.txt
or the most simply case, when you are already in the directory you want to list the contents of:
cd ~/UnixCourse/fileAsst
ls *.txt
Get the idea?
Finally, as you have (accidentally, I'd assume) discovered, you can use .. and . in your paths, to imply "one (sub)directory up" or "the current directory".
For example, the following paths are equivalent and all resolve to "UnixCourse/fileAsst":
UnixCourse/../UnixCourse/fileAsst/
UnixCourse/SomeOtherDir/../fileAsst/
UnixCourse/./fileAsst
UnixCourse/fileAsst/YetAnotherDir/../
Note that this is a orthogonal concept and can be used with both, relative and absolute, paths.
There are two classes of pathname:
Absolute: start with a slash.
Relative: don't start with a slash.
Absolute pathnames have the same meaning regardless of your current working directory. An absolute pathname might contain .. components after the initial slash. An absolute pathname with no .. components that traverses no symlinks is sometimes known as a 'real path', after the system call realpath() that can be used to determine the real path of a name.
Relative pathnames are relative to the current working directory; conceptually, every relative pathname could be deemed to start with ./. A relative name might start with .. to move upwards from the current working directory. A special case of relative pathname is a simple filename — a name with no explicit directory component. That is a file (or other named object) in the current directory, of course.
To determine a relative pathname from an absolute pathname, you also have to know the current working directory.
For more information, see:
bash — Convert absolute path into relative path given a current directory
How to get relative path from absolute path — tagged .net and applying to Windows rather than Unix.
Absolute Path:
The absolute path is a path that contains the root directory and all other sub directories that contain a file or folder.
~/UnixCourse/fileAsst/*.txt
Relative path:
The relative path is only a portion of the full path.
cd ~UnixCourse/fileAsst/
ls *.txt
Didn't see a one-lined answer...
ls ../fileAsst/*.txt
Hope that can help someone!

Resources