rakefile.rb doesn't work correctly - rake

I have the following task
task :default => ['build_html']
desc 'Generar documentacion desde markdown'
task :build_html do
SRC = FileList['*.md']
directory 'html'
SRC.each do |md|
html = md.sub(/\.[^.]*$/, '.html')
file html do
sh "markdown #{md} > html/#{html}"
end
end
end
It does not work correctly, is supposed to find all files .md, for each file extract only the name, append .html and finally execute markdown file.md > html/file.html.
But it doesn't work. It doesn't even create the 'html' directory.
i have installed ruby-1.9.2 with rvm

Finally I was tired and I resolved as follows
task :default => ['build_html']
desc 'Generar documentacion desde markdown'
task :build_html do
SRC = FileList['*.md']
SRC.each do |md|
html = md.sub(/\.[^.]*$/, ".html")
sh "markdown #{md} > html/#{html}"
end
end

Related

Powershell, modify TXT/XML file to add a string after a specific variable?

Trying to edit the DyanmoSettings.xml file without installing any specific packages on the Windows systems (sed, awk, etc)
to do:
need to modify this file;
%appdata%\dynamo\Dynamo Revit\2.3\DynamoSettings.xml
and within that file above, find this line;
>
> <CustomPackageFolders>
> <string>C:\Users\user1.mydomain\AppData\Roaming\Dynamo\Dynamo Revit\2.3</string>
> </CustomPackageFolders>
>
and add 'C:\Users%USERNAME%\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages '
so it looks like this;
>
> <CustomPackageFolders>
> <string>C:\Users\user1.mydomain\AppData\Roaming\Dynamo\Dynamo Revit\2.3</string>
> <string>C:\Users\%USERNAME%\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages </string>
> </CustomPackageFolders>
>
>
TIA!
tried using standard >> method in CMD but this didn't work.
Powershell uses c#. So any c# code can run inside powershell without any installation. Code below uses the c# library Xml Linq. Try following
using assembly System
using assembly System.Xml.Linq
$Filename = "c:\temp\test.xml"
$xDoc = [System.Xml.Linq.XDocument]::Load($Filename)
$customFolder = $xDoc.Descendants("CustomPackageFolders")
$newElement = [System.Xml.Linq.XElement]::new("string","C:\Users\%USERNAME%\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages")
$customFolder.Add($newElement)
Write-Host "customFolder = " $customFolder
$xDoc.Save("c:\temp\test1.xml")
If that xml file looks anything like this
<DynamOconfig>
<CustomPackageFolders>
<string>C:\Users\user1.mydomain\AppData\Roaming\Dynamo\Dynamo Revit\2.3</string>
</CustomPackageFolders>
</DynamOconfig>
then
# load the settings file
$xml = [System.Xml.XmlDocument]::new()
$xml.Load("$env:APPDATA\dynamo\Dynamo Revit\2.3\DynamoSettings.xml")
# create a new <string> node
$newNode = $xml.CreateElement('string')
$newNode.InnerText = 'C:\Users\%USERNAME%\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages'
# find the <CustomPackageFolders> node and append the new node to it
[void]$xml.SelectSingleNode('//CustomPackageFolders').AppendChild($newNode)
# save to (for safety NEW) file
$xml.Save("$env:APPDATA\dynamo\Dynamo Revit\2.3\NEW_DynamoSettings.xml")
Result:
<DynamOconfig>
<CustomPackageFolders>
<string>C:\Users\user1.mydomain\AppData\Roaming\Dynamo\Dynamo Revit\2.3</string>
<string>C:\Users\%USERNAME%\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages</string>
</CustomPackageFolders>
</DynamOconfig>
P.S. If your intention is to have %USERNAME% interpolated in the string so it expands to your username, then create the new node's innertext like ths:
$newNode.InnerText = "C:\Users\$env:USERNAME\OneDrive\DT-s\Revit Scripts\Dynamo\Custom Packages"
(mind you need double-quotes now)

breathe cannot find C# interface

I'm trying to use doxygen, breathe and sphinx to generate documentation for a C# library. This is under Windows. The basic directory structure is:
docs
index.rst
conf.py
xml
xml output from doxygen
I'm running into the following error when I execute make.bat html:
C:\Programming\J4JLogging\J4JLogging\docs\index.rst:25: WARNING: doxygeninterface: Cannot find class "IJ4JLoggerConfiguration" in doxygen xml output for project "J4JLogger" from directory: ./xml
Here's the contents of conf.py
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
project = 'J4JLogger'
copyright = '2019, Mark Olbert'
author = 'Mark Olbert'
extensions = [ "breathe" ]
breathe_projects = {
"J4JLogger": "./xml"
}
breathe_default_project = "J4JLogger"
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
and here's the contents of index.rst:
.. J4JLogger documentation master file, created by
sphinx-quickstart on Tue Jun 11 16:33:34 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to J4JLogger's documentation!
=====================================
.. toctree::
:maxdepth: 2
:caption: Contents:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Docs
====
.. doxygeninterface:: IJ4JLoggerConfiguration
:members:
The contents of the xml folder created by doxygen looks like this:

Cake Task output log to file

I have a set of Tasks inside a build.cake file and I would like to capture the log output from the console into a log file. I know it's possible to use the OnError() function to output errors to file but I would like to output everything to a log file, not just errors.
Below is an example of the build.cake file.
#load "SomeTask.cake"
#load "SomeOtherTask.cake"
var target = Argument("target", "Default");
var someTask = Task("SomeTask")
.Does(() =>
{
SomeMethodInsideSomeTask();
});
var someOtherTask = Task("SomeOtherTask")
.Does(() =>
{
SomeOtherMethodInsideSomeOtherTask();
});
Task("Default")
.IsDependentOn(someTask)
.IsDependentOn(someOtherTask);
RunTarget(target);
N.B. The Tasks are not running any sort of MSBuild commands so it's not possible to use MSBuildFileLogger.
How about pipe the stdout to a file i.e.
./build.ps1 > log.txt
Have you heard about tee ?
It reads standard input and writes it to both standard output and one or more files

Examples of using SCons with knitr

Are there minimal, or even larger, working examples of using SCons and knitr to generate reports from .Rmd files?
kniting an cleaning_session.Rmd file from the command line (bash shell) to derive an .html file, may be done via:
Rscript -e "library(knitr); knit('cleaning_session.Rmd')".
In this example, Rscript and instructions are fed to a Makefile:
RMDFILE=test
html :
Rscript -e "require(knitr); require(markdown); knit('$(RMDFILE).rmd', '$(RMDFILE).md'); markdownToHTML('$(RMDFILE).md', '$(RMDFILE).html', options=c('use_xhtml', 'base64_images')); browseURL(paste('file://', file.path(getwd(),'$(RMDFILE).html'), sep=''
In this answer https://stackoverflow.com/a/10945832/1172302, there is reportedly a solution using SCons. Yet, I did not test enough to make it work for me. Essentially, it would be awesome to have something like the example presented at https://tex.stackexchange.com/a/26573/8272.
[Updated] One working example is an Sconstruct file:
import os
environment = Environment(ENV=os.environ)
# define a `knitr` builder
builder = Builder(action = '/usr/local/bin/knit $SOURCE -o $TARGET',
src_suffix='Rmd')
# add builders as "Knit", "RMD"
environment.Append( BUILDERS = {'Knit' : builder} )
# define an `rmarkdown::render()` builder
builder = Builder(action = '/usr/bin/Rscript -e "rmarkdown::render(input=\'$SOURCE\', output_file=\'$TARGET\')"',
src_suffix='Rmd')
environment.Append( BUILDERS = {'RMD' : builder} )
# define source (and target files -- currently useless, since not defined above!)
# main cleaning session code
environment.RMD(source='cleaning_session.Rmd', target='cleaning_session.html')
# documentation of the Cleaning Process
environment.Knit(source='Cleaning_Process.Rmd', target='Cleaning_Process.html')
# documentation of data
environment.Knit(source='Code_Book.Rmd', target='Code_Book.html')
The first builder calls the custom script called knit. Which, in turn, takes care of the target file/extension, here being cleaning_session.html. Likely the suffix parameter is not needed altogether, in this very example.
The second builder added is Rscript -e "rmarkdown::render(\'$SOURCE\')"'.
The existence of $TARGETs (as in the example at Command wrapper) ensures SCons won't repeat work if a target file already exists.
The custom script (whose source I can't retrieve currently) is:
#!/usr/bin/env Rscript
local({
p = commandArgs(TRUE)
if (length(p) == 0L || any(c('-h', '--help') %in% p)) {
message('usage: knit input [input2 input3] [-n] [-o output output2 output3]
-h, --help to print help messages
-n, --no-convert do not convert tex to pdf, markdown to html, etc
-o output filename(s) for knit()')
q('no')
}
library(knitr)
o = match('-o', p)
if (is.na(o)) output = NA else {
output = tail(p, length(p) - o)
p = head(p, o - 1L)
}
nc = c('-n', '--no-convert')
knit_fun = if (any(nc %in% p)) {
p = setdiff(p, nc)
knit
} else {
if (length(p) == 0L) stop('no input file provided')
if (grepl('\\.(R|S)(nw|tex)$', p[1])) {
function(x, ...) knit2pdf(x, ..., clean = TRUE)
} else {
if (grepl('\\.R(md|markdown)$', p[1])) knit2html else knit
}
}
mapply(knit_fun, p, output = output, MoreArgs = list(envir = globalenv()))
})
The only thing, now, necessary is to run scons.

How to solve this warning: failed to open stream: No such file or directory

Recently, I had a problem as:
Warning:include(C:\xampp\htdocs\crackverbal\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\crackverbal\system\core\Exceptions.php on line 269
Warning: include(): Failed opening 'C:\xampp\htdocs\crackverbal\application\views\errors\html\error_php.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\crackverbal\system\core\Exceptions.php on line 269
Warning: include(C:\xampp\htdocs\crackverbal\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\xampp\htdocs\crackverbal\system\core\Exceptions.php on line 269
Warning: include(): Failed opening 'C:\xampp\htdocs\crackverbal\application\views\errors\html\error_php.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\crackverbal\system\core\Exceptions.php on line 269
I used Xampp and codeigniter-3.
I am guessing that
Under application\view\errors\html\ Folder, error_php.php file does not exist Or
Under application\view\ Folder, errors folder does not exist at all.
You can create dummy file and see if there is any error.
Under application/view/, create folder name errors,
then in errors folder, create folder name html
then in html folder, create php file name error_php.php
In error_php.php,
<?php echo "Sample text."; ?>
Just copy error folders in your codeigniter application to codeigniter view folder.
It will correct error page path. And the warnings will removed.
copy "errors" folder from "codeigniter3/application/views" and paste it into your project ("my_project/application/views").
Paste the below code into index.php
$view_folder = '';
// The path to the "views" folder
if ( ! is_dir($view_folder))
{
if ( ! empty($view_folder) && is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
{
$view_folder = APPPATH.$view_folder;
}
elseif ( ! is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
{
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
exit(3); // EXIT_CONFIG
}
else
{
$view_folder = APPPATH.'views';
}
}
if (($_temp = realpath($view_folder)) !== FALSE)
{
$view_folder = $_temp.DIRECTORY_SEPARATOR;
}
else
{
$view_folder = rtrim($view_folder, '/\\').DIRECTORY_SEPARATOR;
}
define('VIEWPATH', $view_folder);
You should download a fresh codeigniter folder and copy the error folder in the views folder.
Paste it in your own views folder.
please check your folder name may have a space like like: localhost/code igniter/welcome
I just copied "errors" folder from "codeigniter3/application/views" in newly unzipped codeigniter3 folder and paste it into my project ("my_project/application/views"). It solved the problem :)
Create application / view / folder,
in errors folder, create html folder
create php filename error_php.php in the html folder
Check the routs.php file in application>config/routs.php file and change $route['default_controller'] = 'welcome'
to
$route['default_controller'] = 'your default controller name';