Say I want to enter information in an Org file that could be displayed in a tree-like format. Can Org help me with this?
For example I want Org to display a hierarchy of entities as follows:
ROOT
├── foo
│ └── bar
├── baz
├── bax
├── src
│ ├── main
│ │ ├── java
│ │ │ └── something
│ │ └── fine
│ ├── yes
│ └── no
How can I enter this information in a way that Org understands it so that it can render the tree as above?
You might be interested by ditaa block for this:
#+name: tree
#+begin_src ditaa
ROOT
|
+--foo
| +----bar
|
+--baz
+--bax
+--src
| +--main
| | +---java
| | | +---something
| | |
| | +---fine
| |
| +--yes
| +--no
#+end_src
typing C-c ` in the src block will put you in artist-mode, a mode made for editing ascii art and that should make editing those tree easier.
Assuming ROOT is a title that you would want displayed, you can do something like
* ROOT
** foo
*** bar
** baz
** bax
** src
*** main
**** java
***** something
**** fine
*** yes
*** no
The empty lines are optional. I just use them for readability.
If you only want to use one asterisk per level, checkout this link which explains how you can modify org-mode to use indentation and a single asterisk.
If the directory already exists you can use tree, as explained here. I've tried both and had issue with executing ditaa sometimes (emacs couln't find the ditaa.jar in some installations). Furthermore, ditaa output is an image, but the output of tree is text. You can use a src_block like this:
#+BEGIN_SRC sh :results output :exports results
tree /path/to/dir
#+END_SRC
Related
I have the next tree:
root_project/
├── app
│ ├── default_photo_profile.jpg
│ ├── config.py
│ ├── __main__.py # My app are python package, I'm runnig it via "python -m"
│ └── ...
├── tests
│ ├── test_unit.py # import config.py inside
│ ├── functional # import config.py inside
│ ├── pytest.ini
│ └── ...
...
Currently default_photo_profile causing error because tests doesn't have this file.
Reading file in config.py:
DEFAULT_PHOTO_FILE_PATH = Path('default_photo.jpg')
with open(file=DEFAULT_PHOTO_FILE_PATH, mode='rb') as file_obj:
DEFAULT_PHOTO_BYTES = file_obj.read()
How I can solve this?
I tried:
Patch access to default_photo.jpg with fixture - not helped, error during import stage, not executiion.
set flag to pytest comamnd line: --rootdir app - not helped (don't know why).
try/except for reading the file in app.config.py - may help but it's not my intention, I really want raise error if file not found
Put default_photo.jpg inside EVERY test directory - will help bit dirty.
Patch os.path like suggested in https://stackoverflow.com/a/43003192/11277611 - dirty
Include tests into package (move __main__.py into root_project - not sure that it's a good idea (have not enough experience to decide).
Set absolut path to default_photo.jpg - will fail on the production server.
Probably adoptable solutions (What I want):
Set root dir to root_project.app somehow inside pytest.ini to immitate regular execution.
Set root dir to root_project.tests somehow to place file in root of tests and access from any of tests folder.
Try to use following code in config.py:
DEFAULT_PHOTO_FILE_PATH = Path(__file__).parent / 'default_photo.jpg'
with open(file=DEFAULT_PHOTO_FILE_PATH, mode='rb') as file_obj:
DEFAULT_PHOTO_BYTES = file_obj.read()
Is it what you are trying to achieve?
I wrote a little wget command to download a page + all links that belong to the same directory, but only one level deep.
wget -Ekpx -np -l 1 -D <domain> <page>
The flags:
E: adjust-extension
k: convert-links
p: page-requisites
r: recursive
np: no-parent
l: level
D: domains
This works great for a lot of sites, but I had issues with this site in particular.
wget -Ekpr -np -l 1 -D www.eurocanadians.ca https://www.eurocanadians.ca/2022/02/the-origins-of-the-personal-computer-and-what-you-can-do-about-it.html
It treats the html file as a directory:
└── www.eurocanadians.ca
├── 2022
│ └── 02
│ └── the-origins-of-the-personal-computer-and-what-you-can-do-about-it.html
│ └── feed
When I replace the -r flag with -x (--force-directories), I get this result:
└── www.eurocanadians.ca
├── 2022
│ └── 02
│ └── the-origins-of-the-personal-computer-and-what-you-can-do-about-it.html
It treats it as a html file (as it should), but it's a single page download and doesn't download all the first level links.
How to let the page be treated as html, but still use -r? -F (--force-html) didn't work btw.
my directory structure is
├── xxx
│ ├── 01.md
| └── 02.md
├── auth
│ ├── j1.json
│ ├── j2.json
│ └── j3.json
└── default.template.html
And I link jsons from markdowns like Auth. It makes sense as we use there files as test scenarios and in json files we have credentials and roles. But if I try to generate html it fails on unresolved internal reference: ../auth/aspect_admin.json. I tried to exclude the link checking but without any help. The best would be to leave it as a link in md file but somehow follow the link and include the json as code block in generated html. Is it possible?
It was a bug and will be fixed in next version https://github.com/planet42/Laika/issues/148
I would like to fake the LED (character device) of an embedded linux board (BeagleBone Black) in a user space library written in D.
Via the command line the led driver is represented to the user space as "device file" (e.g. for led "USER LEDS D2 0"):
debian#beaglebone:/sys/class/leds/beaglebone:green:usr0$ tree
.
├── brightness
├── device -> ../../../leds
├── invert
├── max_brightness
├── power
│ ├── async
│ ├── autosuspend_delay_ms
│ ├── control
│ ├── runtime_active_kids
│ ├── runtime_active_time
│ ├── runtime_enabled
│ ├── runtime_status
│ ├── runtime_suspended_time
│ └── runtime_usage
├── subsystem -> ../../../../../class/leds
├── trigger
└── uevent
Via the command line single entities like e.g. the brightness (turn on and off) can be written to and read from like files:
cd /sys/class/leds/beaglebone:green:usr0
echo none > trigger
echo 1 > brightness
echo 0 > brightness
I consider it reasonable to abstract the whole device as interface and implement a production class and a test class (hand-made fake object) which implements the interface. The client code of the library could then use either the production code or the fake class which could be injected using dependency injection.
Could a mock framework like https://github.com/QAston/DMocks-revived provide functionality to use a fake driver in client code out of the box instead of using the handmade fake led driver described above? (I guess to fake more complicated character devices it would be necessary to "hand-implement" anyway.)
Or are there better approaches to fake a character device (e.g. make the production class require a root path of the driver when creating an instance via "constructor injection")?
I am documenting a matlab code that I have with sphinx. I am using the package sphinxcontrib-matlabdomain.
My directory tree is as follows:
me:~/.../doc$ tree ../
../
├── doc
│ ├── conf.py
│ ├── make.bat
│ ├── Makefile
│ ├── index.rst
│ ├── BaseClass.rst
│ └── DerivedClass.rst
├── LICENSE.md
├── README.md
└── src
├── BaseClass.m
└── DerivedClass.m
The problem comes when I want to show inheritance diagrams. I have added the necessary things in my config.py file:
matlab_src_dir = os.path.abspath('..')
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.inheritance_diagram',
'sphinx.ext.graphviz',
'sphinx.ext.viewcode',
'sphinxcontrib.matlab',
]
primary_domain = 'mat'
And I have the following in the index.rst file
Welcome to BGK's documentation!
===============================
I am trying to have a diagram here...
.. inheritance-diagram:: BaseClass DerivedClass
:parts:2
.. graphviz::
digraph {
"From here" -> "To" -> "Somewhere";
"From here" -> "To" -> "Somewhere else";
}
And in the output the directive inheritance-diagram is ignored, obtaining directly the next diagram that I am using to test that I can plot diagrams.
Is there any incompatibility to plot inheritance diagrams with sphinx for matlab classes? Is there any way to go around the problem? Thanks!
Sphinx does not support this. The built-in sphinx.ext.inheritance_diagram extension is for the Python domain only. It does not work for Matlab. If it did, I'm sure it would say so in the Sphinx documentation (and a glance at the source code in sphinx/ext/inheritance_diagram.py confirms that it is only for Python).
The only way inheritance diagrams for Matlab could work is if some other extension provided the functionality. The sphinxcontrib-matlabdomain extension that you use does not.