Skip to content
Snippets Groups Projects
Commit 069cefe8 authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

individual documentation of 1 method

parent 9727bb2e
No related branches found
No related tags found
No related merge requests found
Package: Mediawikir Package: Mediawikir
Type: Package Type: Package
Title: Connects to a mediawiki instance and writes in it what you want. Provides classes Mediawikir and Batchator. Title: Connects to a mediawiki instance and writes in it what you want. Provides classes Mediawikir and Batchator.
Version: 0.1.12 Version: 0.1.13
Author: Mathieu Loiseau Author: Mathieu Loiseau
Maintainer: Mathieu Loiseau <loiseaum@univ-grenoble-alpes.fr> Maintainer: Mathieu Loiseau <loiseaum@univ-grenoble-alpes.fr>
Description: Mediawikir class can be used to post the output of an R script directly into a mediawiki instance. Batchator class allows batch page creation. Description: Mediawikir class can be used to post the output of an R script directly into a mediawiki instance. Batchator class allows batch page creation.
......
...@@ -289,9 +289,23 @@ Mediawikir <- R6Class("Mediawikir", ...@@ -289,9 +289,23 @@ Mediawikir <- R6Class("Mediawikir",
}, },
###### ######
# replaceSingleLineTemplateField #' Replaces a field of a template in the selected \code{page}.
#'
#' This method does not work with numbered parameters. If the sought field does not exist, adds it at the beginning of the template.
#'
#' Right now it works only for pages that only contain one occurence of the parameter (it does not take outer context into account)
#'
#' Additionnally, this function is not made for templates the value of which spans accross multiple lines.
#' @param field The name of the field concerned
#' @param newValue The new value of the field
#' @return A message logging operations
#' @examples
#' obj <- Mediawikir$new("http://wiki.lezinter.net", "user","pass","installDir")
#' obj$setPage("Title of the page to modify (or its ID)")
#' obj$replaceSingleLineTemplateField("attribute","new value")
#' #Will replace |attribute=* by |attribute=new value (or create it)
###### ######
replaceSingleLineTemplateField = function(field="", newValue="", template=""){ replaceSingleLineTemplateField = function(field="", newValue=""){
success <- self$getContent() success <- self$getContent()
if(success != FALSE){ if(success != FALSE){
search <- paste("\\|", field, "\\=[^\\|\\}\\n]*", sep="") search <- paste("\\|", field, "\\=[^\\|\\}\\n]*", sep="")
......
...@@ -65,6 +65,13 @@ A Mediawikir controller serves to connect to a mediawiki API as a registered use ...@@ -65,6 +65,13 @@ A Mediawikir controller serves to connect to a mediawiki API as a registered use
\item{\code{newValue}}{The new value of the field} \item{\code{newValue}}{The new value of the field}
}} }}
} }
Replaces a field of a template in the selected \code{page}.
This method does not work with numbered parameters. If the sought field does not exist, adds it at the beginning of the template.
Right now it works only for pages that only contain one occurence of the parameter (it does not take outer context into account)
Additionnally, this function is not made for templates the value of which spans accross multiple lines.
} }
\examples{ \examples{
...@@ -77,6 +84,15 @@ A Mediawikir controller serves to connect to a mediawiki API as a registered use ...@@ -77,6 +84,15 @@ A Mediawikir controller serves to connect to a mediawiki API as a registered use
mwHandler$addContent(paste("[[",fileName,"]]",sep="")) mwHandler$addContent(paste("[[",fileName,"]]",sep=""))
mwHandler$postContent() mwHandler$postContent()
mwHandler$replaceSingleLineTemplateField("attribute", "newValue") mwHandler$replaceSingleLineTemplateField("attribute", "newValue")
## ------------------------------------------------
## Method `Mediawikir$replaceSingleLineTemplateField`
## ------------------------------------------------
obj <- Mediawikir$new("http://wiki.lezinter.net", "user","pass","installDir")
obj$setPage("Title of the page to modify (or its ID)")
obj$replaceSingleLineTemplateField("attribute","new value")
#Will replace |attribute=* by |attribute=new value (or create it)
} }
\keyword{mediawiki} \keyword{mediawiki}
\section{Public fields}{ \section{Public fields}{
...@@ -171,11 +187,30 @@ A Mediawikir controller serves to connect to a mediawiki API as a registered use ...@@ -171,11 +187,30 @@ A Mediawikir controller serves to connect to a mediawiki API as a registered use
\if{html}{\out{<a id="method-replaceSingleLineTemplateField"></a>}} \if{html}{\out{<a id="method-replaceSingleLineTemplateField"></a>}}
\subsection{Method \code{replaceSingleLineTemplateField()}}{ \subsection{Method \code{replaceSingleLineTemplateField()}}{
\subsection{Usage}{ \subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{Mediawikir$replaceSingleLineTemplateField( \if{html}{\out{<div class="r">}}\preformatted{Mediawikir$replaceSingleLineTemplateField(field = "", newValue = "")}\if{html}{\out{</div>}}
field = "", }
newValue = "",
template = "" \subsection{Arguments}{
)}\if{html}{\out{</div>}} \if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{field}}{The name of the field concerned}
\item{\code{newValue}}{The new value of the field}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
A message logging operations
}
\subsection{Examples}{
\if{html}{\out{<div class="r example copy">}}
\preformatted{obj <- Mediawikir$new("http://wiki.lezinter.net", "user","pass","installDir")
obj$setPage("Title of the page to modify (or its ID)")
obj$replaceSingleLineTemplateField("attribute","new value")
#Will replace |attribute=* by |attribute=new value (or create it)
}
\if{html}{\out{</div>}}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment