Compile all rustdoc comments in project folder into single markdown file - rust

Let's say I have the following directory structure in a VSCode project:
- MY_EXAMPLES
- Example_1
- src
- main.rs
- Cargo.lock
- Cargo.toml
- Example_2
- src
- main.rs
- Cargo.lock
- Cargo.toml
Now I want to compile the comments from all main.rs files. In this case, that'd be MY_EXAMPLES/Example_1/src/main.rs and MY_EXAMPLES/Example_2/src/main.rs. Note that I would like this solution to scale, so I could automatically compile the comments if I had 10 or 20 Example_X folders.
MY_EXAMPLES/Example_1/src/main.rs
/// My notes on Example 1 that I'd like to add to my README.md
fn main(){
//..
}
MY_EXAMPLES/Example_2/src/main.rs
/// My notes on Example 2 that I'd like to add to my README.md
fn main(){
//..
}
Running:
C:\Users\Primary User\Desktop\MY_EXAMPLES> cargo doc
should create a README.md file that looks like:
Example_1
My notes on Example 1 that I'd like to add to my README.md
Example_2
My notes on Example 2 that I'd like to add to my README.md
So our general template for the README.md content is something like:
### Project Rootdir
rustdoc comments
Does rustdoc have any kind of templating system, similar to that of JSDoc, etc?
I've also seen this similar question, which is currently without an answer.

Related

Application restarting after SQLite Database updates

i am learning Tauri and want to use a SQLite Database with the diesel ORM.
Problem
The App ist always restarting after a change in the Databasefile.
Finished dev [unoptimized + debuginfo] target(s) in 0.56s
Info File src-tauri/DB.db changed. Rebuilding application...
warning: #[table_name] attribute form is deprecated
= help: use `#[diesel(table_name = categories)]` instead
i got the example from here:
https://morioh.com/p/ea3442d4bb16
I already found out, that you need to add the
TAURI_DEV_WATCHER_IGNORE_FILE=.taurignore
variable in the .env file and wrtie: store.sqlite but it seems like its not working.
Information
Versions
diesel = {version="2.0.3", features=["sqlite"]}
Basic Folderstructure
projectname/
├── .env
├── .taurignore
└── src-tauri/
├── main.rs
└── dbfile.db
taurigrnore file
dbfile.db
How can i implement this properly or is there any Documentation about the .taurignore file?
Solution
Ok i found the Solution the Path in the .taurignore file has to be the relative Path from the root folder:
src-tauri/Db.db
It's a bit hard to follow your question as it misses some important information (like which tauri/diesel/… versions you are using). Based on the included message I would guess that you somehow need to exclude src-tauri/DB.db from the list of monitored files of your watch tool. As information about that tool are missing as well from your question it's not possible to say how to do this.

How do I exclude a folder from the sidebar in Sublime Text permanently, specifying it relative to the open folder?

I've already read this related question (How do I exclude a folder from search in sublime text 3 permanently?) but my question is different since I want to specify only the folder at the open folder's root, not a generic pattern to match at any level in the folder tree.
In Sublime Text 4 I have an open project folder via File --> "Open Folder...".
Let's say my folder layout is this:
mainapp
├── microapp
│ └── node_modules <== don't exclude this (keep it)
├── microapp2
│ └── node_modules <== don't exclude this (keep it)
├── index
├── node_modules <=== exclude this only
├── config
└── assets
I'd like to exclude mainapp/node_modules only, NOT mainapp/microapp/node_modules nor mainapp/microapp2/node_modules. How do I do that?
I'm guessing I need to specify a "folder_exclude_patterns" in the settings.
Side note: why do I need to do this?
Because that folder has so much build content in it (which is constantly-changing as builds occur) that it's actually causing Sublime Text to freeze and lock up and become unusable.
Tested on Linux Ubuntu 18.04.
Through sheer dumb luck and persistence with guessing, I figured it out. // refers to the "open folder root", apparently.
If you want to see this info about // added to the official Sublime Text documentation and default settings file, please upvote my open issue on it here.
Update
I found some official documentation on this: https://www.sublimetext.com/docs/file_patterns.html. The // feature was added as of Sublime Text 4:
If pattern begins with //, it will be compared as a relative path from the project root [added in version 4.0]
My testing, however, proves that the // actually means "path" root, as defined below, however. So, my examples below are still correct.
1. If you have a folder open via File --> "Open Folder...", do this:
Preferences --> Settings --> add this "folder_exclude_patterns" entry to your user settings JSON file:
{
// other user settings here
// exclude only the "mainapp/node_modules" dir
"folder_exclude_patterns": ["//node_modules"],
// other user settings here
}
Again, // means the "open folder's root".
NOTE: Changing your user settings above will apply globally to all of your Sublime Text instances, which may not be what you want. So, it may be better to use a "Project" instead, as described below:
2. If you have the folder open and saved as part of a project, do this:
Project --> Edit Project --> add this "folder_exclude_patterns" entry to your Project settings JSON file:
{
"folders":
[
{
// path to an open folder in a project
"path": "/path/to/mainapp",
// exclude only the "mainapp/node_modules" dir
"folder_exclude_patterns": ["//node_modules"],
}
],
}
You can see in the official project settings file example here (https://www.sublimetext.com/docs/projects.html) that the "folder_exclude_patterns" entry must be at the same level in the JSON settings file as the "path" entry.
I also first learned this from #smhg's comment here. Thank you!
To open another folder in your project, go to Project --> "Add Folder to Project...". Once you have multiple folders open in your project, you'll have to add multiple entries of "folder_exclude_patterns", as desired, like this:
{
"folders":
[
{
// **absolute path** to open a folder in a project
"path": "/path/to/mainapp",
// exclude only the "mainapp/node_modules" dir
"folder_exclude_patterns": ["//node_modules"],
},
{
// or **relative path** to open another folder in the project;
// the path is relative to the location of the
// "project_name.sublime-project" project file itself
"path": "some_dir",
// exclude only the "some_dir/path/to/excluded_folder" dir
"folder_exclude_patterns": ["//path/to/excluded_folder"],
},
],
}
Bonus: How to create a project in Sublime Text:
To create a Project from an open folder, the steps are like this:
Open a folder: File --> "Open Folder..."
Save it as part of a project: Project --> "Save Project As..."
Now you can choose where to save your project_name.sublime-project file. This is the file you are editing when you go to Project --> "Edit Project" above. To open a project go to Project --> "Open Project...".
See also:
Issue I opened: https://github.com/sublimehq/sublime_text/issues/5234
Comment I wrote on the Sublime Text forum: https://forum.sublimetext.com/t/a-way-to-specify-root-in-project-settings/7756/4?u=ercaguy
Official Project settings documentation: https://www.sublimetext.com/docs/projects.html. This includes:
Each object must have a "path" key, which may be relative to the project directory, or a fully qualified path.
How do I exclude a folder from search in sublime text 3 permanently? - answer which explains how to exclude a file or folder from the side bar in Sublime Text, versus excluding a file or folder from search, such as Goto Anything or Find in Files.

Can't display multiple .md files in .rst toctree Sphinx

I can render my Readme.md files in Sphinx using recommonmark. But when I try to put in multiple Readme files in a .rst file toctree only the first one can be accessed from the documentation link.
Kick! KVM
=========
Source Code: https://bitbucket-eng-rtp1.cisco.com/bitbucket/projects/KICK/repos/kickdb/browse/kick/kvm
ReadMe
------
.. toctree::
:maxdepth: 2
./README.md
Tests ReadMe
------------
.. toctree::
:maxdepth: 2
./tests/README.md
KVM Module Code
---------------
.. automodule:: kick.kvm.actions
:members:
:undoc-members:
I can see the both the Readme files in the folder structure, but the links don't work when trying to access them from the rendered html page.
Here is an image for the folder structure.
Any help appreciated, Thanks!
Here is the error that pops up in the Sphinx build -
/workspace/kick_device2/kick/kvm/kvm.rst:16: WARNING: toctree contains
reference to document 'kick/kvm/tests/README' that doesn't have a
title: no link will be generated
The warning indicates you need to add a title to the file tests/README.md. Sphinx considers the h1 level to be the title of a page. From the markdown syntax documentation:
# My Title
or
My Title
========

Why does hiera look in the "services" subdirectory?

I have been experimenting with hiera for configuration data. The hiera.yaml file has the following configuration:
---
:backends:
- yaml
:hierarchy:
- "servers/%{hostname}"
- common
but when I run hiera from the command line to test it,
hiera some::var hostname=foo
it does not pick up the configuration from servers/foo/yaml. Adding the -d (debug) option shows that it doesn't even look at that file. Instead, it says something like:
Looking for data source services/foo
Cannot find database /etc/puppet/hiera/services/foo.yaml, skipping
So, two questions:
Why is it not looking in the servers directory?
Why is it looking in a "services" directory? (Note that it looks for things in the services directory even if we remove the "servers/%{::hostname}" line from the hiera.yaml file!)
If by default hiera looks for things in special directories like "services", then where is this documented?
I think the reason may be that a) you are not using the default location for hiera datadir (which is /var/lib/hiera) and b) you have forgotten to specify that datadir within the hiera.yaml (or whatever filename you want your hiera config file to be). That is what a possible solution might be is just adding the following to your hiera config file:
:yaml:
:datadir: /tmp/var-lib-hiera
Check out the following example:
/tmp/var-lib-hiera $ hiera -c hiera.yaml some::var hostname=foo
100
/tmp/var-lib-hiera $ tree
.
├── hiera.yaml
└── servers
└── foo.yaml
/tmp/var-lib-hiera $ head hiera.yaml servers/foo.yaml
==> hiera.yaml <==
---
:backends:
- yaml
:hierarchy:
- "servers/%{hostname}"
- common
:yaml:
:datadir: /tmp/var-lib-hiera
==> servers/foo.yaml <==
some::var: 100
Apparently, the configuration will work if: hiera is run with the -c option to specify the exact location of the configuration file. (A symlink from /etc/hiera.yaml did not work, though that was a suggestion from another forum https://ask.puppetlabs.com/question/3149/where-does-hiera-search-for-data-sources/?answer=3152#post-id-3152)
If you are using puppet you can set the location of the hiera file in e master section of puppet.conf so you don't have to provide it on cmd line.
See: http://docs.puppetlabs.com/references/latest/configuration.html#hieraconfig

Submodules in puppet?

Can you make submodules in puppet, for instance have...
puppet_root
- modules
- module_1
- submodule
- manifests
- init.pp
I've tried this and puppet doesn't seem to like it. I could change my submodule init.pp's into more descriptive filenames and get rid of the directories all together but some of the modules have more than one file and that will clutter things up.
The reason I'm doing this is to put all of the OS tools together into one "super" module, so it can be more self-documenting: eg. os_tools::lsof, etc.
puppet structure goes like this :
/etc/puppet/modules/modulename/manifests/init.pp
class modulename{
-----
}
submodule1 and submodule2 can be directories inside /etc/puppet/modules/modulename/manifests/
and each of them can contain .pp files. for example:
/etc/puppet/modules/modulename/manifests/submodule1/foo.pp
class modulename::submodule1::foo{
notify{"I am in modulename->submodule1->foo":}
}
You can include the class like this:
include modulename::submodule1::foo

Resources