<commit_before>#!/usr/bin/ruby
#
#	MUES Documentation Generation Script
#	$Id: makesitedocs.rb,v 1.7 2002/07/07 18:12:20 deveiant Exp $
#
#	Copyright (c) 2001,2002 The FaerieMUD Consortium.
#
#	This is free software. You may use, modify, and/or redistribute this
#	software under the terms of the Perl Artistic License. (See
#	http://language.perl.com/misc/Artistic.html)
#

# Muck with the load path and the cwd
$filename = __FILE__
$basedir = File::expand_path( $0 ).sub( %r{/docs/makesitedocs.rb}, '' )
unless $basedir.empty? || Dir.getwd == $basedir
	$stderr.puts "Changing working directory from '#{Dir.getwd}' to '#$basedir'"
	Dir.chdir( $basedir ) 
end

$LOAD_PATH.unshift "docs/lib"

# Load modules
require 'getoptlong'
require 'rdoc/rdoc'
require 'rdoc/parsers/parse_faeriemud_rb'
require 'utils'
include UtilityFunctions

opts = GetoptLong.new
opts.set_options(
	[ '--debug',	'-d',	GetoptLong::NO_ARGUMENT ],
	[ '--verbose',	'-v',	GetoptLong::NO_ARGUMENT ],
	[ '--upload',	'-u',	GetoptLong::REQUIRED_ARGUMENT ]
)

$docsdir = "docs/html"
$libdirs = %w{lib ext server README INSTALL QUICKSTART CONFIGURATION}
opts.each {|opt,val|
	case opt

	when '--debug'
		$debug = true

	when '--verbose'
		$verbose = true

	when '--upload'
		$upload = val

	end
}


header "Making documentation in #$docsdir from files in #{$libdirs.join(', ')}."

flags = [
	'--all',
	'--inline-source',
	'--main', 'README',
	'--fmt', 'html',
	'--include', 'docs',
	'--template', 'mues',
	'--op', $docsdir,
	'--title', "Multi-User Environment Server (MUES)"
]

flags += [ '--quiet' ] unless $verbose
message "Running 'rdoc #{flags.join(' ')} #{$libdirs.join(' ')}'\n" if $verbose


unless $debug
	begin
		r = RDoc::RDoc.new
		r.document( flags + $libdirs  )
	rescue RDoc::RDocError => e
		$stderr.puts e.message
		exit(1)
	end
end

if $upload
	header "Uploading new docs snapshot to #$upload."
	case $upload
	
	# SSH target
	when %r{^ssh://(.*)}
		target = $1
		if target =~ %r{^([^/]+)/(.*)}
			host, path = $1, $2
			path = "/" + path unless path =~ /^(\/|\.)/
			cmd = "tar -C docs/html -cf - . | ssh #{host} 'tar -C #{path} -xvf -'"
			unless $debug
				system( cmd )
			else
				message "Would have uploaded using the command:\n    #{cmd}\n\n"
			end
		else
			error "--upload ssh://host/path"
		end
	else
		targetdir = $upload
		targetdir.gsub!( %r{^file://}, '' )

		File.makedirs targetdir, true
		Dir["docs/html/**/*"].each {|file|
			fname = file.gsub( %r{docs/html/}, '' )
			if File.directory? file
				unless $debug
					File.makedirs File.join(targetdir, fname), true
				else
					message %{File.makedirs %s, true\n} % File.join(targetdir, fname)
				end
			else
				unless $debug
					File.install( file, File.join(targetdir, fname), 0444, true )
				else
					message %{File.install( %s, %s, 0444, true )\n} % [
						file,
						File.join(targetdir, fname),
					]
				end
			end
		}
	end
end


# rdoc \<commit_msg>- Added default upload target.<commit_after>#!/usr/bin/ruby
#
#	MUES Documentation Generation Script
#	$Id: makesitedocs.rb,v 1.8 2002/08/02 20:12:14 deveiant Exp $
#
#	Copyright (c) 2001,2002 The FaerieMUD Consortium.
#
#	This is free software. You may use, modify, and/or redistribute this
#	software under the terms of the Perl Artistic License. (See
#	http://language.perl.com/misc/Artistic.html)
#

# Muck with the load path and the cwd
$filename = __FILE__
$basedir = File::expand_path( $0 ).sub( %r{/docs/makesitedocs.rb}, '' )
unless $basedir.empty? || Dir.getwd == $basedir
	$stderr.puts "Changing working directory from '#{Dir.getwd}' to '#$basedir'"
	Dir.chdir( $basedir ) 
end

$LOAD_PATH.unshift "docs/lib"

# Load modules
require 'getoptlong'
require 'rdoc/rdoc'
#require 'rdoc/parsers/parse_faeriemud_rb'
require 'utils'
include UtilityFunctions

opts = GetoptLong.new
opts.set_options(
	[ '--debug',	'-d',	GetoptLong::NO_ARGUMENT ],
	[ '--verbose',	'-v',	GetoptLong::NO_ARGUMENT ],
	[ '--upload',	'-u',	GetoptLong::OPTIONAL_ARGUMENT ]
)

$docsdir = "docs/html"
$libdirs = %w{lib ext/mues server README INSTALL QUICKSTART CONFIGURATION}
opts.each {|opt,val|
	case opt

	when '--debug'
		$debug = true

	when '--verbose'
		$verbose = true

	when '--upload'
		$upload = unless val.empty?
					  val
				  else
					  'ssh://oberon/www/mues.FaerieMUD.org/public/rdoc'
				  end
		debugMsg "Setting upload arg to #$upload"

	end
}


header "Making documentation in #$docsdir from files in #{$libdirs.join(', ')}."
message "Will upload to '#$upload'" if $upload

flags = [
	'--all',
	'--inline-source',
	'--main', 'README',
	'--fmt', 'html',
	'--include', 'docs',
	'--template', 'mues',
	'--op', $docsdir,
	'--title', "Multi-User Environment Server (MUES)"
]

flags += [ '--quiet' ] unless $verbose
message "Running 'rdoc #{flags.join(' ')} #{$libdirs.join(' ')}'\n" if $verbose


unless $debug
	begin
		r = RDoc::RDoc.new
		r.document( flags + $libdirs  )
	rescue RDoc::RDocError => e
		$stderr.puts e.message
		exit(1)
	end
end

if $upload
	header "Uploading new docs snapshot to #$upload."
	case $upload
	
	# SSH target
	when %r{^ssh://(.*)}
		target = $1
		if target =~ %r{^([^/]+)/(.*)}
			host, path = $1, $2
			path = "/" + path unless path =~ /^(\/|\.)/
			cmd = "tar -C docs/html -cf - . | ssh #{host} 'tar -C #{path} -xvf -'"
			unless $debug
				system( cmd )
			else
				message "Would have uploaded using the command:\n    #{cmd}\n\n"
			end
		else
			error "--upload ssh://host/path"
		end
	when %r{^file://(.*)}
		targetdir = $1
		targetdir.gsub!( %r{^file://}, '' )

		File.makedirs targetdir, true
		Dir["docs/html/**/*"].each {|file|
			fname = file.gsub( %r{docs/html/}, '' )
			if File.directory? file
				unless $debug
					File.makedirs File.join(targetdir, fname), true
				else
					message %{File.makedirs %s, true\n} % File.join(targetdir, fname)
				end
			else
				unless $debug
					File.install( file, File.join(targetdir, fname), 0444, true )
				else
					message %{File.install( %s, %s, 0444, true )\n} % [
						file,
						File.join(targetdir, fname),
					]
				end
			end
		}

	else
		raise "I don't know how to upload to urls like #$upload."
	end
end


# rdoc \
{'fraction_non_alphanumeric': 0.17820973538059456, 'fraction_numerical': 0.012250898399215943, 'mean_word_length': 3.2111416781292985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2089032', 'n_tokens_mistral': 2674, 'n_tokens_neox': 2321, 'n_words': 617}