How to cross-reference already existing doxygen docs? - c++

I have two C++ projects A and B; The dependency is only B to A.
B --> A
I would like to separately run Doxygen on A and B respectively but still let me possible cross reference on A from B doc. (That is, when I browse B doc, I can directly link to the A doc if there is any Class from A used in B).
--
[Replied the answer from 0x4b:]
if I set "CREATE_SUBDIRS" with YES and use relative path for tag files, Doxygen will somehow make wrong linking reference.
I did follow the example.
<root>
+- proj
| +- html HTML output directory for proj
| +- d1
| | +- d2
| | .... (*.html)
| |
| ...(*.html)
| +- src sources for proj
+- ext1
| +- html HTML output directory for ext1
| |- ext1.tag tag file for ext1
|- proj.cfg doxygen configuration file for proj
|- ext1.cfg doxygen configuration file for ext1
proj.cfg:
OUTPUT_DIRECTORY = proj
INPUT = proj/src
TAGFILES = ext1/ext1.tag=../../ext1/html
ext1.cfg:
OUTPUT_DIRECTORY = ext1
GENERATE_TAGFILE = ext1/ext1.tag
The documents under both html/ and html/d1/d2 would like to try linking external doc located in ../../ext1/html. Apparently one of them will fail.

You probably want to use the tagfile feature. When you generate the documentation for A, make sure the GENERATE_TAGFILE option is set. When you generate the documentation for B, set the value of TAGFILES to include the result from A.
[Update to address relative paths]
Doxygen is fairly fragile when it comes to [relative] paths. You clearly understand that using an absolute path will solve the problem. You could try taking a value from the environment, e.g. using
TAGFILES = ext1/ext1.tag=$(PWD)/../ext1/html
to create an absolute path. It's not ideal, but a lot of the values in the Doxyfile depend on where doxygen is run, and not where the configuration file lives.

Related

Flask: Include common template to multiple blueprints

How could I implement a common template to be included in two Flask blueprints?
I am trying to create the following structure in my application:
app
+-- bp
| +-- hello
| | +-- templates
| | | +-- hello
| | | +-- hello.html
| | +-- routes.py
| +-- world
| + etc
+-- templates
+-- common_incl.html
in hello.html, I try to include another file by {% include '/templates/common_incl.html' %} but I always get a TemplateNotFound exception.
I would not like to expose the common_incl.html in static folder, as it isn't static but has Jinja variables expressions.
Re-reading https://flask.palletsprojects.com/en/2.0.x/blueprints/#templates might provide some guidance.
Depending on the nature of your application (and your blueprints) either put the base templates in the application's templates folder, or use a third blueprint that does nothing but hold common templates for your two templates.

yaml file not getting copied when installing from setup.py

for my distutils package the yaml file along with python files is not getting copied
setup.py
from distutils.core import setup
files = ["*.yaml", "package/*"]
setup(name = "mypackage",
version = "0.1",
description = "description",
author = "Ciasto",
author_email = "me#email.com",
packages = ['package'],
package_data = {'package' : files },
scripts = ["scripts/runner"],
)
this is the project directory structure:
$ tree package/
|____
| |______init__.py
| |____command.py
| |____constants.py
| |____controller.py
| |____utils.py
| |____model.py
| |____products.yaml
package_data is used to add package's data to eggs (dropped in favor) and wheels (not with distutils). You're probably generating source distribution (sdist).
For sdist you need file MANIFEST.in (create it besides setup.py). In your case it should be enough to have one line in it:
include package/*.yaml
See the docs at https://docs.python.org/3/distutils/sourcedist.html#specifying-the-files-to-distribute
and
https://packaging.python.org/guides/using-manifest-in/#using-manifest-in
If you're not going to create wheels you can safely remove files and package_data from setup.py.

How to import multiple class objects from seperate folders?

I built a python 2.7 application with the below directory structure for my relevant files. How do cal methods located in different folder locations?
Data-Wrangling-OpenStreetMap-data
|
+---- process_data
| |
| +---- __init__.py
| |
| +---- data_cleaner.py
|
+---- main_code.py
|
+---- audit _data
| |
| +---- __init__.py
| |
| +---- audit_file.py
I have succeeded in doing it correctly for one class referenced from main_code.py via the use of:
from process_data.data_cleaner import DataCleaner
However, if attempt a similar pattern for another class located in seperate folder referenced by main_code.py for via the use of the import statement
from audit_data.audit_file import AuditFile
I get the error:
ImportError: No module named audit_data.audit_file
Any ideas as to what I may be overlooking and/or guidance on what further details I need to post to help find the solution to my problem?
from process_data.data_cleaner import data_cleaner
as data_cleaner is the file name data_cleaner.py and the second one data_cleaner is a class defined in it.
The cause of my problem was a silly one;
The folder containing the class I was calling was named audit _file whilst the folder I was calling within my code was audit_file
What didnt work
from audit_data.audit_file import AuditFile
What worked
from audit _data.audit_file import AuditFile
For those reading this watch out for unintended spaces in your folder names

why Django put application at the same level of my project folder?

since Django 1.4 (I think) django create a folder for my project when I start a project. Django add a folder for any application I created (with python manage.py startapp) at the same level of my project folder.
Project_name
|---project_name_dir/
|---application_dir/
`---manage.py
I really like the following folder structure:
Project_name
|---project_name_dir/
| |---application_dir/
| | |-- __init__.py
| | |-- models.py
| | |-- tests.py
| | `-- views.py
| |-- __init__.py
| |-- settings.py
| |-- urls.py
| |-- wsgi.py
| |---templates/
| | `---application_dir/
| `---static/
| |---css/
| |---font/
| |---img/
| `---js/
|---deployment/
|---documentation/
|---config/
`---manage.py
Because I have a folder with all my django files (project_name_dir/) and other directories for non django files.
So why Django put application at the same level of my project folder?
In Django, the position of the application directory is not considered. Django only uses the name of the application.
Thus, the position of the application is basically a matter of convenience of the programmer.
This is also the reason why two apps should not have the same name: even if they are imported in INSTALLED_APPS as
('app.app1', 'app1')
Django only concerns with the last part after the dot, i.e. app1.
So, in the end, you can use the directory structure you want, as long as the apps' names don't collide and you point to the app on INSTALLED_APPS. Because of this, if there isn't any special reason, you should put them on the project's root, like Django does.

Editing Word Document, add Headers/footers and save it - Python

I want to add headers and footers to every page of a word document, and want to add some pages to the start of the document, how can I do this using python ? I have tried python-docx but it is not working as I expected. Is there any other way to achieve my requirement ?
I think the best way you can take is looking at python-docx to see how it manages the files. Docx is a zipped format (Docx Tag Wiki):
The .docx format is a zipped file that contains the following folders:
+--docProps
| + app.xml
| \ core.xml
+ res.log
+--word //this folder contains most of the files that control the content of the document
| + document.xml //Is the actual content of the document
| + endnotes.xml
| + fontTable.xml
| + footer1.xml //Containst the elements in the footer of the document
| + footnotes.xml
| +--media //This folder contains all images embedded in the word
| | \ image1.jpeg
| + settings.xml
| + styles.xml
| + stylesWithEffects.xml
| +--theme
| | \ theme1.xml
| + webSettings.xml
| \--_rels
| \ document.xml.rels //this document tells word where the images are situated
+ [Content_Types].xml
\--_rels
\ .rels
A library like docx-python extracts at first the docx, so you could find it in the python docx: I have found it for you: https://github.com/mikemaccana/python-docx/blob/master/docx.py#L65
def opendocx(file):
'''Open a docx file, return a document XML tree'''
mydoc = zipfile.ZipFile(file)
xmlcontent = mydoc.read('word/document.xml')
document = etree.fromstring(xmlcontent)
return document
You can get the xmlcontent of 'word/document.xml' which is the main content of the docx, change it either using docx-python (which I recommend to you, docx-python seems to be able to add many different elements. If you want to copy the content of an other word document at the beginning of the document, you could probably try to copy the content of the document.xml to your document.xml, but It will probably give you some errors, specially if you use Images or non-text content.
To add a header or a footer, you will have to create a file word/header1.xml or a word/footer1.xml You could just copy the header1.xml content of a file you created, this should work.
Hope this helps